@liberseek/boft-cli-win32-arm64 0.7.8 → 0.7.9
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/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +16583 -16433
- package/app/console-web.js +3524 -1714
- package/app/desktop-controller.mjs +16241 -350
- package/app/host-runtime.mjs +4343 -954
- package/app/plugins/antigravity/plugin.mjs +81 -0
- package/app/plugins/claude-code/plugin.mjs +393 -100
- package/app/plugins/codebuddy/plugin.mjs +727 -134
- package/app/plugins/cursor-cli/plugin.mjs +431 -120
- package/app/plugins/deepseek-harness/plugin.mjs +81 -0
- package/app/plugins/enabled.json +2 -1
- package/app/plugins/grok/plugin.mjs +459 -56
- package/app/plugins/hermes/plugin.mjs +3301 -7739
- package/app/plugins/kimi-code/plugin.mjs +367 -40
- package/app/plugins/kiro-cli/plugin.mjs +374 -35
- package/app/plugins/muse/plugin.mjs +81 -0
- package/app/plugins/omp/plugin.mjs +505 -97
- package/app/plugins/opencode/plugin.mjs +324 -76
- package/app/plugins/pi/plugin.mjs +195 -55
- package/app/plugins/qoder/plugin.mjs +281 -35
- package/app/plugins/qoder-cn/plugin.mjs +281 -35
- package/app/plugins/workbuddy/plugin.mjs +699 -96
- package/app/plugins/zcode/assets/icon.svg +8 -0
- package/app/plugins/zcode/manifest.json +14 -0
- package/app/plugins/zcode/plugin.mjs +19304 -0
- package/app/renderer-extension.js +2514 -526
- 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/package.json +1 -1
|
@@ -1253,10 +1253,10 @@ function mergeDefs(...defs) {
|
|
|
1253
1253
|
function cloneDef(schema) {
|
|
1254
1254
|
return mergeDefs(schema._zod.def);
|
|
1255
1255
|
}
|
|
1256
|
-
function getElementAtPath(obj,
|
|
1257
|
-
if (!
|
|
1256
|
+
function getElementAtPath(obj, path10) {
|
|
1257
|
+
if (!path10)
|
|
1258
1258
|
return obj;
|
|
1259
|
-
return
|
|
1259
|
+
return path10.reduce((acc, key) => acc?.[key], obj);
|
|
1260
1260
|
}
|
|
1261
1261
|
function promiseAllObject(promisesObj) {
|
|
1262
1262
|
const keys = Object.keys(promisesObj);
|
|
@@ -1665,11 +1665,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1665
1665
|
}
|
|
1666
1666
|
return false;
|
|
1667
1667
|
}
|
|
1668
|
-
function prefixIssues(
|
|
1668
|
+
function prefixIssues(path10, issues) {
|
|
1669
1669
|
return issues.map((iss) => {
|
|
1670
1670
|
var _a3;
|
|
1671
1671
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1672
|
-
iss.path.unshift(
|
|
1672
|
+
iss.path.unshift(path10);
|
|
1673
1673
|
return iss;
|
|
1674
1674
|
});
|
|
1675
1675
|
}
|
|
@@ -1816,16 +1816,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1816
1816
|
}
|
|
1817
1817
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1818
1818
|
const fieldErrors = { _errors: [] };
|
|
1819
|
-
const processError = (error52,
|
|
1819
|
+
const processError = (error52, path10 = []) => {
|
|
1820
1820
|
for (const issue2 of error52.issues) {
|
|
1821
1821
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1822
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1822
|
+
issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
|
|
1823
1823
|
} else if (issue2.code === "invalid_key") {
|
|
1824
|
-
processError({ issues: issue2.issues }, [...
|
|
1824
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
1825
1825
|
} else if (issue2.code === "invalid_element") {
|
|
1826
|
-
processError({ issues: issue2.issues }, [...
|
|
1826
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
1827
1827
|
} else {
|
|
1828
|
-
const fullpath = [...
|
|
1828
|
+
const fullpath = [...path10, ...issue2.path];
|
|
1829
1829
|
if (fullpath.length === 0) {
|
|
1830
1830
|
fieldErrors._errors.push(mapper(issue2));
|
|
1831
1831
|
} else {
|
|
@@ -1852,17 +1852,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1852
1852
|
}
|
|
1853
1853
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1854
1854
|
const result = { errors: [] };
|
|
1855
|
-
const processError = (error52,
|
|
1855
|
+
const processError = (error52, path10 = []) => {
|
|
1856
1856
|
var _a3, _b;
|
|
1857
1857
|
for (const issue2 of error52.issues) {
|
|
1858
1858
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1859
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1859
|
+
issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
|
|
1860
1860
|
} else if (issue2.code === "invalid_key") {
|
|
1861
|
-
processError({ issues: issue2.issues }, [...
|
|
1861
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
1862
1862
|
} else if (issue2.code === "invalid_element") {
|
|
1863
|
-
processError({ issues: issue2.issues }, [...
|
|
1863
|
+
processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
|
|
1864
1864
|
} else {
|
|
1865
|
-
const fullpath = [...
|
|
1865
|
+
const fullpath = [...path10, ...issue2.path];
|
|
1866
1866
|
if (fullpath.length === 0) {
|
|
1867
1867
|
result.errors.push(mapper(issue2));
|
|
1868
1868
|
continue;
|
|
@@ -1894,8 +1894,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1894
1894
|
}
|
|
1895
1895
|
function toDotPath(_path) {
|
|
1896
1896
|
const segs = [];
|
|
1897
|
-
const
|
|
1898
|
-
for (const seg of
|
|
1897
|
+
const path10 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1898
|
+
for (const seg of path10) {
|
|
1899
1899
|
if (typeof seg === "number")
|
|
1900
1900
|
segs.push(`[${seg}]`);
|
|
1901
1901
|
else if (typeof seg === "symbol")
|
|
@@ -14587,13 +14587,13 @@ function resolveRef(ref, ctx) {
|
|
|
14587
14587
|
if (!ref.startsWith("#")) {
|
|
14588
14588
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14589
14589
|
}
|
|
14590
|
-
const
|
|
14591
|
-
if (
|
|
14590
|
+
const path10 = ref.slice(1).split("/").filter(Boolean);
|
|
14591
|
+
if (path10.length === 0) {
|
|
14592
14592
|
return ctx.rootSchema;
|
|
14593
14593
|
}
|
|
14594
14594
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14595
|
-
if (
|
|
14596
|
-
const key =
|
|
14595
|
+
if (path10[0] === defsKey) {
|
|
14596
|
+
const key = path10[1];
|
|
14597
14597
|
if (!key || !ctx.defs[key]) {
|
|
14598
14598
|
throw new Error(`Reference not found: ${ref}`);
|
|
14599
14599
|
}
|
|
@@ -15081,6 +15081,10 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
|
15081
15081
|
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
15082
15082
|
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
15083
15083
|
|
|
15084
|
+
// ../../shared-contracts/dist/thread-prewarm.js
|
|
15085
|
+
var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
|
|
15086
|
+
var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
|
|
15087
|
+
|
|
15084
15088
|
// ../../shared-contracts/dist/harness-plugins.js
|
|
15085
15089
|
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
15086
15090
|
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
@@ -15148,6 +15152,9 @@ var consoleOpenResultSchema = external_exports.strictObject({
|
|
|
15148
15152
|
url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
|
|
15149
15153
|
});
|
|
15150
15154
|
var CONSOLE_HOST_METHODS = Object.freeze([
|
|
15155
|
+
"codexhost/console/remote-connections",
|
|
15156
|
+
"codexhost/runtime/status",
|
|
15157
|
+
"codexhost/remote/ssh-setup",
|
|
15151
15158
|
"codexhost/harness/plugins/list",
|
|
15152
15159
|
"codexhost/harness/display-settings/get",
|
|
15153
15160
|
"codexhost/harness/display-settings/set",
|
|
@@ -16093,6 +16100,80 @@ var updateStatusResultSchema = external_exports.strictObject({
|
|
|
16093
16100
|
status: updateStatusSchema.nullable()
|
|
16094
16101
|
});
|
|
16095
16102
|
|
|
16103
|
+
// ../../shared-contracts/dist/remote-runtime.js
|
|
16104
|
+
var remoteUpdatePhaseSchema = external_exports.enum([
|
|
16105
|
+
"idle",
|
|
16106
|
+
"installing",
|
|
16107
|
+
"restarting",
|
|
16108
|
+
"succeeded",
|
|
16109
|
+
"failed"
|
|
16110
|
+
]);
|
|
16111
|
+
var runtimeStatusSchema = external_exports.object({
|
|
16112
|
+
runningVersion: external_exports.string().nullable(),
|
|
16113
|
+
installedVersion: external_exports.string().nullable(),
|
|
16114
|
+
restartRequired: external_exports.boolean(),
|
|
16115
|
+
remote: external_exports.boolean(),
|
|
16116
|
+
updateSupported: external_exports.boolean(),
|
|
16117
|
+
update: external_exports.object({
|
|
16118
|
+
phase: remoteUpdatePhaseSchema,
|
|
16119
|
+
targetVersion: external_exports.string().nullable(),
|
|
16120
|
+
error: external_exports.string().nullable()
|
|
16121
|
+
})
|
|
16122
|
+
});
|
|
16123
|
+
var remoteUpdateParamsSchema = external_exports.object({
|
|
16124
|
+
version: external_exports.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
|
|
16125
|
+
}).strict();
|
|
16126
|
+
var remoteSshSetupParamsSchema = external_exports.object({
|
|
16127
|
+
hostname: external_exports.string().min(1).max(1024).refine((value) => !value.startsWith("-") && !/\s/u.test(value)),
|
|
16128
|
+
port: external_exports.number().int().min(1).max(65535).nullable(),
|
|
16129
|
+
identity: external_exports.string().max(4096).nullable(),
|
|
16130
|
+
action: external_exports.enum(["inspect", "install", "update", "repair", "uninstall"]),
|
|
16131
|
+
uninstallPackage: external_exports.boolean().optional(),
|
|
16132
|
+
version: external_exports.string().regex(/^\d+\.\d+\.\d+$/u).nullable()
|
|
16133
|
+
}).strict();
|
|
16134
|
+
var remoteSshSetupResultSchema = external_exports.object({ state: external_exports.enum(["installed", "not-installed"]) }).strict();
|
|
16135
|
+
|
|
16136
|
+
// ../../shared-contracts/dist/remote-connections.js
|
|
16137
|
+
var hostId = external_exports.string().min(1).max(1024);
|
|
16138
|
+
var codexSshConnectionSchema = external_exports.object({
|
|
16139
|
+
hostId,
|
|
16140
|
+
displayName: external_exports.string().min(1).max(1024),
|
|
16141
|
+
source: external_exports.enum(["codex-managed", "discovered"]),
|
|
16142
|
+
sshAlias: external_exports.string().max(1024).nullable(),
|
|
16143
|
+
sshHost: external_exports.string().min(1).max(1024),
|
|
16144
|
+
sshPort: external_exports.number().int().min(1).max(65535).nullable(),
|
|
16145
|
+
identity: external_exports.string().max(4096).nullable(),
|
|
16146
|
+
autoConnect: external_exports.boolean(),
|
|
16147
|
+
connectionAnalyticsId: external_exports.string().max(1024).optional()
|
|
16148
|
+
});
|
|
16149
|
+
var codexSshDraftSchema = external_exports.strictObject({
|
|
16150
|
+
displayName: external_exports.string().min(1).max(1024),
|
|
16151
|
+
hostname: external_exports.string().min(1).max(1024),
|
|
16152
|
+
sshPort: external_exports.number().int().min(1).max(65535).nullable(),
|
|
16153
|
+
identity: external_exports.string().max(4096).nullable()
|
|
16154
|
+
});
|
|
16155
|
+
var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
|
|
16156
|
+
external_exports.strictObject({ action: external_exports.literal("list") }),
|
|
16157
|
+
external_exports.strictObject({
|
|
16158
|
+
action: external_exports.literal("save"),
|
|
16159
|
+
draft: codexSshDraftSchema,
|
|
16160
|
+
previous: codexSshConnectionSchema.nullable()
|
|
16161
|
+
}),
|
|
16162
|
+
external_exports.strictObject({ action: external_exports.literal("remove"), previous: codexSshConnectionSchema }),
|
|
16163
|
+
external_exports.strictObject({ action: external_exports.literal("connect"), hostId, enabled: external_exports.boolean() }),
|
|
16164
|
+
external_exports.strictObject({ action: external_exports.literal("state"), hostId }),
|
|
16165
|
+
external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
|
|
16166
|
+
external_exports.strictObject({
|
|
16167
|
+
action: external_exports.literal("update"),
|
|
16168
|
+
hostId: hostId.refine((id) => id !== "local"),
|
|
16169
|
+
version: remoteUpdateParamsSchema.shape.version
|
|
16170
|
+
})
|
|
16171
|
+
]);
|
|
16172
|
+
var remoteConnectionsReplySchema = external_exports.union([
|
|
16173
|
+
external_exports.strictObject({ result: jsonValueSchema }),
|
|
16174
|
+
external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
|
|
16175
|
+
]);
|
|
16176
|
+
|
|
16096
16177
|
// ../../shared-contracts/dist/index.js
|
|
16097
16178
|
var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
|
|
16098
16179
|
|
|
@@ -16441,6 +16522,44 @@ async function bounded(operation, milliseconds, label, onTimeout) {
|
|
|
16441
16522
|
}
|
|
16442
16523
|
}
|
|
16443
16524
|
|
|
16525
|
+
// dist/command.js
|
|
16526
|
+
var codeBuddyDiscoverySpec = {
|
|
16527
|
+
id: "codebuddy",
|
|
16528
|
+
command: "codebuddy",
|
|
16529
|
+
commandEnvironmentVariable: "CODEXHOST_CODEBUDDY_COMMAND",
|
|
16530
|
+
installRoots: {
|
|
16531
|
+
windows: ["${APPDATA}/npm", "~/.local/bin", VERSION_MANAGER_ROOTS],
|
|
16532
|
+
posix: [
|
|
16533
|
+
"~/.local/bin",
|
|
16534
|
+
"~/.npm-global/bin",
|
|
16535
|
+
VERSION_MANAGER_ROOTS,
|
|
16536
|
+
"/opt/homebrew/bin",
|
|
16537
|
+
"/usr/local/bin"
|
|
16538
|
+
]
|
|
16539
|
+
}
|
|
16540
|
+
};
|
|
16541
|
+
function codeBuddyInvocation(environment, ephemeral, argumentsOverride) {
|
|
16542
|
+
const resolved = resolveHarnessExecutable(codeBuddyDiscoverySpec, { environment });
|
|
16543
|
+
if (!resolved)
|
|
16544
|
+
throw new CodeBuddyError("notInstalled", "CLI is not installed; run codebuddy and sign in first");
|
|
16545
|
+
const env = withNodeRuntimeOnPath(environment);
|
|
16546
|
+
return {
|
|
16547
|
+
...commandInvocation(resolved.executable, argumentsOverride ?? [
|
|
16548
|
+
"--acp",
|
|
16549
|
+
...ephemeral ? ["--no-session-persistence"] : [],
|
|
16550
|
+
...!ephemeral && [
|
|
16551
|
+
"CODEXHOST_CLI_PATH",
|
|
16552
|
+
"CODEXHOST_RUNTIME_ENDPOINT",
|
|
16553
|
+
"CODEXHOST_RUNTIME_TOKEN",
|
|
16554
|
+
"CODEXHOST_THREAD_ID"
|
|
16555
|
+
].every((key) => environment[key]) ? ["--append-system-prompt", CODEBUDDY_DELEGATION_INSTRUCTIONS] : []
|
|
16556
|
+
], env),
|
|
16557
|
+
environment: env
|
|
16558
|
+
};
|
|
16559
|
+
}
|
|
16560
|
+
var CODEBUDDY_DELEGATION_INSTRUCTIONS = `This Session runs inside codexhost.
|
|
16561
|
+
When the user requests cross-Harness agent delegation, use the executable at the CODEXHOST_CLI_PATH environment variable through your native shell tool. Start with its --help and harness list commands, then use delegate start and thread send/read/wait/cancel as documented by the CLI. Pass --format compact when reporting results. Keep the inherited CODEXHOST_RUNTIME_ENDPOINT, CODEXHOST_RUNTIME_TOKEN and CODEXHOST_THREAD_ID environment variables for all such calls; they identify this Runtime and parent Thread. Do not print or expose their values, replace the configured executable, or start delegation unless the user's request authorizes it. Native CodeBuddy Agent subagents remain available for CodeBuddy-only work.`;
|
|
16562
|
+
|
|
16444
16563
|
// dist/slash-commands.js
|
|
16445
16564
|
var excluded = /* @__PURE__ */ new Set([
|
|
16446
16565
|
"background",
|
|
@@ -16519,7 +16638,7 @@ function commandPrompt(command, catalog, profile = CODEBUDDY_RUNTIME_PROFILE) {
|
|
|
16519
16638
|
}
|
|
16520
16639
|
|
|
16521
16640
|
// dist/codebuddy-adapter.js
|
|
16522
|
-
import { stat as
|
|
16641
|
+
import { stat as stat3 } from "node:fs/promises";
|
|
16523
16642
|
|
|
16524
16643
|
// dist/acp-client.js
|
|
16525
16644
|
import { execFile as execFile2, spawn } from "node:child_process";
|
|
@@ -20748,44 +20867,6 @@ var CodeBuddyCopyCleanup = class {
|
|
|
20748
20867
|
}
|
|
20749
20868
|
};
|
|
20750
20869
|
|
|
20751
|
-
// dist/command.js
|
|
20752
|
-
var codeBuddyDiscoverySpec = {
|
|
20753
|
-
id: "codebuddy",
|
|
20754
|
-
command: "codebuddy",
|
|
20755
|
-
commandEnvironmentVariable: "CODEXHOST_CODEBUDDY_COMMAND",
|
|
20756
|
-
installRoots: {
|
|
20757
|
-
windows: ["${APPDATA}/npm", "~/.local/bin", VERSION_MANAGER_ROOTS],
|
|
20758
|
-
posix: [
|
|
20759
|
-
"~/.local/bin",
|
|
20760
|
-
"~/.npm-global/bin",
|
|
20761
|
-
VERSION_MANAGER_ROOTS,
|
|
20762
|
-
"/opt/homebrew/bin",
|
|
20763
|
-
"/usr/local/bin"
|
|
20764
|
-
]
|
|
20765
|
-
}
|
|
20766
|
-
};
|
|
20767
|
-
function codeBuddyInvocation(environment, ephemeral, argumentsOverride) {
|
|
20768
|
-
const resolved = resolveHarnessExecutable(codeBuddyDiscoverySpec, { environment });
|
|
20769
|
-
if (!resolved)
|
|
20770
|
-
throw new CodeBuddyError("notInstalled", "CLI is not installed; run codebuddy and sign in first");
|
|
20771
|
-
const env = withNodeRuntimeOnPath(environment);
|
|
20772
|
-
return {
|
|
20773
|
-
...commandInvocation(resolved.executable, argumentsOverride ?? [
|
|
20774
|
-
"--acp",
|
|
20775
|
-
...ephemeral ? ["--no-session-persistence"] : [],
|
|
20776
|
-
...!ephemeral && [
|
|
20777
|
-
"CODEXHOST_CLI_PATH",
|
|
20778
|
-
"CODEXHOST_RUNTIME_ENDPOINT",
|
|
20779
|
-
"CODEXHOST_RUNTIME_TOKEN",
|
|
20780
|
-
"CODEXHOST_THREAD_ID"
|
|
20781
|
-
].every((key) => environment[key]) ? ["--append-system-prompt", CODEBUDDY_DELEGATION_INSTRUCTIONS] : []
|
|
20782
|
-
], env),
|
|
20783
|
-
environment: env
|
|
20784
|
-
};
|
|
20785
|
-
}
|
|
20786
|
-
var CODEBUDDY_DELEGATION_INSTRUCTIONS = `This Session runs inside codexhost.
|
|
20787
|
-
When the user requests cross-Harness agent delegation, use the executable at the CODEXHOST_CLI_PATH environment variable through your native shell tool. Start with its --help and harness list commands, then use delegate start and thread send/read/wait/cancel as documented by the CLI. Pass --format compact when reporting results. Keep the inherited CODEXHOST_RUNTIME_ENDPOINT, CODEXHOST_RUNTIME_TOKEN and CODEXHOST_THREAD_ID environment variables for all such calls; they identify this Runtime and parent Thread. Do not print or expose their values, replace the configured executable, or start delegation unless the user's request authorizes it. Native CodeBuddy Agent subagents remain available for CodeBuddy-only work.`;
|
|
20788
|
-
|
|
20789
20870
|
// dist/acp-client.js
|
|
20790
20871
|
var CodeBuddyAcpClient = class {
|
|
20791
20872
|
options;
|
|
@@ -21145,16 +21226,16 @@ var Diff = class {
|
|
|
21145
21226
|
}
|
|
21146
21227
|
}
|
|
21147
21228
|
}
|
|
21148
|
-
addToPath(
|
|
21149
|
-
const last =
|
|
21229
|
+
addToPath(path10, added, removed, oldPosInc, options) {
|
|
21230
|
+
const last = path10.lastComponent;
|
|
21150
21231
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
21151
21232
|
return {
|
|
21152
|
-
oldPos:
|
|
21233
|
+
oldPos: path10.oldPos + oldPosInc,
|
|
21153
21234
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
21154
21235
|
};
|
|
21155
21236
|
} else {
|
|
21156
21237
|
return {
|
|
21157
|
-
oldPos:
|
|
21238
|
+
oldPos: path10.oldPos + oldPosInc,
|
|
21158
21239
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
21159
21240
|
};
|
|
21160
21241
|
}
|
|
@@ -22960,6 +23041,345 @@ async function deriveCodeBuddySession(options) {
|
|
|
22960
23041
|
}
|
|
22961
23042
|
}
|
|
22962
23043
|
|
|
23044
|
+
// dist/session-import.js
|
|
23045
|
+
import { createReadStream } from "node:fs";
|
|
23046
|
+
import { opendir, readFile as readFile4, stat as stat2 } from "node:fs/promises";
|
|
23047
|
+
import path7 from "node:path";
|
|
23048
|
+
import { createInterface as createInterface2 } from "node:readline";
|
|
23049
|
+
|
|
23050
|
+
// ../../harness-adapter/dist/session-import.js
|
|
23051
|
+
import { lstat as lstat2 } from "node:fs/promises";
|
|
23052
|
+
var SessionImportChangedError = class extends Error {
|
|
23053
|
+
constructor(message = "Native Session changed during discovery; refresh and retry") {
|
|
23054
|
+
super(message);
|
|
23055
|
+
this.name = "SessionImportChangedError";
|
|
23056
|
+
}
|
|
23057
|
+
};
|
|
23058
|
+
function isMissingFileError(error51) {
|
|
23059
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
|
|
23060
|
+
}
|
|
23061
|
+
function sameFileFingerprint(left, right) {
|
|
23062
|
+
return left === null || right === null ? left === right : left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs;
|
|
23063
|
+
}
|
|
23064
|
+
var STORAGE_ACCESS_ERRORS = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"]);
|
|
23065
|
+
function isStorageAccessError(error51) {
|
|
23066
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" && STORAGE_ACCESS_ERRORS.has(error51.code);
|
|
23067
|
+
}
|
|
23068
|
+
async function optionalLstat(file2) {
|
|
23069
|
+
try {
|
|
23070
|
+
return await lstat2(file2);
|
|
23071
|
+
} catch (error51) {
|
|
23072
|
+
if (isMissingFileError(error51))
|
|
23073
|
+
return null;
|
|
23074
|
+
throw error51;
|
|
23075
|
+
}
|
|
23076
|
+
}
|
|
23077
|
+
async function readStableFiles(files, read) {
|
|
23078
|
+
const before = await Promise.all(files.map(optionalLstat));
|
|
23079
|
+
const value = await read(before);
|
|
23080
|
+
const after = await Promise.all(files.map(optionalLstat));
|
|
23081
|
+
if (before.some((info, index) => !sameFileFingerprint(info, after[index] ?? null)))
|
|
23082
|
+
throw new SessionImportChangedError();
|
|
23083
|
+
return value;
|
|
23084
|
+
}
|
|
23085
|
+
function sessionImportTitle(value, maxLength = HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) {
|
|
23086
|
+
if (typeof value !== "string")
|
|
23087
|
+
return null;
|
|
23088
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
23089
|
+
if (!normalized)
|
|
23090
|
+
return null;
|
|
23091
|
+
if (normalized.length <= maxLength)
|
|
23092
|
+
return normalized;
|
|
23093
|
+
const characters = [...normalized];
|
|
23094
|
+
if (characters.length <= maxLength)
|
|
23095
|
+
return normalized;
|
|
23096
|
+
return `${characters.slice(0, maxLength - 1).join("").trimEnd()}…`;
|
|
23097
|
+
}
|
|
23098
|
+
function sessionImportCandidate(input) {
|
|
23099
|
+
const time3 = typeof input.updatedAt === "number" ? input.updatedAt : typeof input.updatedAt === "string" ? Date.parse(input.updatedAt) : Number.NaN;
|
|
23100
|
+
const parsed = harnessSessionImportCandidateSchema.safeParse({
|
|
23101
|
+
nativeSessionId: input.nativeSessionId,
|
|
23102
|
+
cwd: input.cwd,
|
|
23103
|
+
title: typeof input.title === "string" && input.title.trim().length > 0 ? input.title : null,
|
|
23104
|
+
updatedAt: Math.floor(time3),
|
|
23105
|
+
// Unknown must stay unknown; only an explicit boolean is a native statement.
|
|
23106
|
+
running: typeof input.running === "boolean" ? input.running : null
|
|
23107
|
+
});
|
|
23108
|
+
return parsed.success ? parsed.data : null;
|
|
23109
|
+
}
|
|
23110
|
+
var SessionImportScope = class {
|
|
23111
|
+
#abort = new AbortController();
|
|
23112
|
+
#options;
|
|
23113
|
+
#pending = /* @__PURE__ */ new Set();
|
|
23114
|
+
constructor(options) {
|
|
23115
|
+
this.#options = options;
|
|
23116
|
+
}
|
|
23117
|
+
#closed() {
|
|
23118
|
+
return {
|
|
23119
|
+
ok: false,
|
|
23120
|
+
error: { code: "invalidState", message: this.#options.closedMessage, retryable: false }
|
|
23121
|
+
};
|
|
23122
|
+
}
|
|
23123
|
+
read(operation) {
|
|
23124
|
+
const signal = this.#abort.signal;
|
|
23125
|
+
if (signal.aborted)
|
|
23126
|
+
return Promise.resolve(this.#closed());
|
|
23127
|
+
let started;
|
|
23128
|
+
try {
|
|
23129
|
+
started = operation(signal);
|
|
23130
|
+
} catch (error51) {
|
|
23131
|
+
started = Promise.reject(error51 instanceof Error ? error51 : new Error("Session read failed"));
|
|
23132
|
+
}
|
|
23133
|
+
const request = started.then((value) => signal.aborted ? this.#closed() : { ok: true, value }).catch(() => signal.aborted ? this.#closed() : {
|
|
23134
|
+
ok: false,
|
|
23135
|
+
error: {
|
|
23136
|
+
code: "unavailable",
|
|
23137
|
+
message: this.#options.unavailableMessage,
|
|
23138
|
+
retryable: true
|
|
23139
|
+
}
|
|
23140
|
+
}).finally(() => this.#pending.delete(request));
|
|
23141
|
+
this.#pending.add(request);
|
|
23142
|
+
return request;
|
|
23143
|
+
}
|
|
23144
|
+
/** `read` for `resolveCandidate`: a null source is the selected Session having disappeared. */
|
|
23145
|
+
async resolve(operation) {
|
|
23146
|
+
const result = await this.read(operation);
|
|
23147
|
+
if (!result.ok)
|
|
23148
|
+
return result;
|
|
23149
|
+
return result.value ? { ok: true, value: result.value } : {
|
|
23150
|
+
ok: false,
|
|
23151
|
+
error: {
|
|
23152
|
+
code: "sessionNotFound",
|
|
23153
|
+
message: this.#options.notFoundMessage,
|
|
23154
|
+
retryable: false
|
|
23155
|
+
}
|
|
23156
|
+
};
|
|
23157
|
+
}
|
|
23158
|
+
/** Idempotent. Resolves after every started read has settled. */
|
|
23159
|
+
async close() {
|
|
23160
|
+
this.#abort.abort();
|
|
23161
|
+
await Promise.allSettled(this.#pending);
|
|
23162
|
+
}
|
|
23163
|
+
};
|
|
23164
|
+
|
|
23165
|
+
// dist/session-import.js
|
|
23166
|
+
var SESSION_FILE = /^([A-Za-z0-9][A-Za-z0-9_-]{0,199})\.jsonl$/u;
|
|
23167
|
+
var MAX_HISTORY_BYTES = 64e6;
|
|
23168
|
+
var MAX_MARKER_BYTES = 64 * 1024;
|
|
23169
|
+
function processAlive(pid) {
|
|
23170
|
+
if (typeof pid !== "number" || !Number.isSafeInteger(pid) || pid <= 0)
|
|
23171
|
+
return false;
|
|
23172
|
+
try {
|
|
23173
|
+
process.kill(pid, 0);
|
|
23174
|
+
return true;
|
|
23175
|
+
} catch (error51) {
|
|
23176
|
+
return record2(error51).code === "EPERM";
|
|
23177
|
+
}
|
|
23178
|
+
}
|
|
23179
|
+
function userText(row) {
|
|
23180
|
+
if (row.type !== "message" || row.role !== "user")
|
|
23181
|
+
return null;
|
|
23182
|
+
const { content } = row;
|
|
23183
|
+
if (typeof content === "string")
|
|
23184
|
+
return content;
|
|
23185
|
+
if (!Array.isArray(content))
|
|
23186
|
+
return "";
|
|
23187
|
+
return content.map((part) => record2(part)).filter((part) => typeof part.text === "string").map((part) => String(part.text)).join(" ");
|
|
23188
|
+
}
|
|
23189
|
+
async function readFacts(file2, signal) {
|
|
23190
|
+
const stream = createReadStream(file2, { encoding: "utf8", signal });
|
|
23191
|
+
const lines = createInterface2({ input: stream, crlfDelay: Infinity });
|
|
23192
|
+
let cwd = null;
|
|
23193
|
+
let customTitle = null;
|
|
23194
|
+
let generatedTitle = null;
|
|
23195
|
+
let firstPrompt = null;
|
|
23196
|
+
let hasUser = false;
|
|
23197
|
+
let updatedAt = null;
|
|
23198
|
+
try {
|
|
23199
|
+
for await (const line of lines) {
|
|
23200
|
+
signal.throwIfAborted();
|
|
23201
|
+
if (!line.trim())
|
|
23202
|
+
continue;
|
|
23203
|
+
let parsed;
|
|
23204
|
+
try {
|
|
23205
|
+
parsed = JSON.parse(line);
|
|
23206
|
+
} catch {
|
|
23207
|
+
return null;
|
|
23208
|
+
}
|
|
23209
|
+
const row = record2(parsed);
|
|
23210
|
+
if (typeof row.cwd === "string" && path7.isAbsolute(row.cwd))
|
|
23211
|
+
cwd ??= row.cwd;
|
|
23212
|
+
if (typeof row.timestamp === "number" && Number.isFinite(row.timestamp))
|
|
23213
|
+
updatedAt = row.timestamp;
|
|
23214
|
+
if (row.type === "custom-title")
|
|
23215
|
+
customTitle = sessionImportTitle(row.customTitle);
|
|
23216
|
+
else if (row.type === "ai-title")
|
|
23217
|
+
generatedTitle = sessionImportTitle(row.aiTitle);
|
|
23218
|
+
else {
|
|
23219
|
+
const text2 = userText(row);
|
|
23220
|
+
if (text2 !== null) {
|
|
23221
|
+
hasUser = true;
|
|
23222
|
+
firstPrompt ??= sessionImportTitle(text2);
|
|
23223
|
+
}
|
|
23224
|
+
}
|
|
23225
|
+
}
|
|
23226
|
+
} finally {
|
|
23227
|
+
lines.close();
|
|
23228
|
+
stream.destroy();
|
|
23229
|
+
}
|
|
23230
|
+
if (!hasUser || !cwd)
|
|
23231
|
+
return null;
|
|
23232
|
+
return { cwd, title: customTitle ?? generatedTitle ?? firstPrompt, updatedAt };
|
|
23233
|
+
}
|
|
23234
|
+
var CodeBuddySessionImport = class {
|
|
23235
|
+
#environment;
|
|
23236
|
+
#profile;
|
|
23237
|
+
#scope;
|
|
23238
|
+
constructor(environment, profile = CODEBUDDY_RUNTIME_PROFILE) {
|
|
23239
|
+
this.#environment = { ...environment };
|
|
23240
|
+
this.#profile = profile;
|
|
23241
|
+
this.#scope = new SessionImportScope({
|
|
23242
|
+
closedMessage: `${profile.displayName} Session import is closed`,
|
|
23243
|
+
unavailableMessage: `${profile.displayName} sessions could not be read; close native clients, check storage access and retry`,
|
|
23244
|
+
notFoundMessage: `${profile.displayName} Session is no longer importable`
|
|
23245
|
+
});
|
|
23246
|
+
}
|
|
23247
|
+
listCandidates() {
|
|
23248
|
+
return this.#scope.read(async (signal) => {
|
|
23249
|
+
const active = await this.#activeSessions(signal);
|
|
23250
|
+
const candidates = [];
|
|
23251
|
+
for (const [nativeSessionId, files] of await this.#sessionFiles(signal)) {
|
|
23252
|
+
if (files.length !== 1 || !files[0])
|
|
23253
|
+
continue;
|
|
23254
|
+
try {
|
|
23255
|
+
const source = await this.#source(nativeSessionId, files[0], active, signal);
|
|
23256
|
+
if (source)
|
|
23257
|
+
candidates.push(source.candidate);
|
|
23258
|
+
} catch (error51) {
|
|
23259
|
+
if (!(error51 instanceof SessionImportChangedError))
|
|
23260
|
+
throw error51;
|
|
23261
|
+
}
|
|
23262
|
+
}
|
|
23263
|
+
return candidates;
|
|
23264
|
+
});
|
|
23265
|
+
}
|
|
23266
|
+
resolveCandidate(nativeSessionId) {
|
|
23267
|
+
return this.#scope.resolve(async (signal) => {
|
|
23268
|
+
const files = (await this.#sessionFiles(signal)).get(nativeSessionId);
|
|
23269
|
+
if (files?.length !== 1 || !files[0])
|
|
23270
|
+
return null;
|
|
23271
|
+
return this.#source(nativeSessionId, files[0], await this.#activeSessions(signal), signal);
|
|
23272
|
+
});
|
|
23273
|
+
}
|
|
23274
|
+
close() {
|
|
23275
|
+
return this.#scope.close();
|
|
23276
|
+
}
|
|
23277
|
+
#root() {
|
|
23278
|
+
return codeBuddyConfigRoot(this.#environment, this.#profile);
|
|
23279
|
+
}
|
|
23280
|
+
/** IDs a live native process registered in `<config>/sessions/<pid>.json`. */
|
|
23281
|
+
async #activeSessions(signal) {
|
|
23282
|
+
const active = /* @__PURE__ */ new Set();
|
|
23283
|
+
const directory = path7.join(this.#root(), "sessions");
|
|
23284
|
+
const markers = await opendir(directory).catch((error51) => {
|
|
23285
|
+
if (isMissingFileError(error51) || record2(error51).code === "ENOTDIR")
|
|
23286
|
+
return null;
|
|
23287
|
+
throw error51;
|
|
23288
|
+
});
|
|
23289
|
+
if (!markers)
|
|
23290
|
+
return active;
|
|
23291
|
+
for await (const marker of markers) {
|
|
23292
|
+
signal.throwIfAborted();
|
|
23293
|
+
if (!marker.isFile() || !marker.name.endsWith(".json"))
|
|
23294
|
+
continue;
|
|
23295
|
+
try {
|
|
23296
|
+
const file2 = path7.join(directory, marker.name);
|
|
23297
|
+
if ((await stat2(file2)).size > MAX_MARKER_BYTES)
|
|
23298
|
+
continue;
|
|
23299
|
+
const entry = record2(JSON.parse(await readFile4(file2, { encoding: "utf8", signal })));
|
|
23300
|
+
if (typeof entry.sessionId === "string" && processAlive(entry.pid))
|
|
23301
|
+
active.add(entry.sessionId);
|
|
23302
|
+
} catch (error51) {
|
|
23303
|
+
signal.throwIfAborted();
|
|
23304
|
+
if (isStorageAccessError(error51))
|
|
23305
|
+
throw error51;
|
|
23306
|
+
}
|
|
23307
|
+
}
|
|
23308
|
+
return active;
|
|
23309
|
+
}
|
|
23310
|
+
/** Session ID to every project file claiming it. Enumerated links are not followed. */
|
|
23311
|
+
async #sessionFiles(signal) {
|
|
23312
|
+
const root = path7.join(this.#root(), "projects");
|
|
23313
|
+
const found = /* @__PURE__ */ new Map();
|
|
23314
|
+
const info = await optionalLstat(root);
|
|
23315
|
+
if (!info)
|
|
23316
|
+
return found;
|
|
23317
|
+
if (!info.isDirectory())
|
|
23318
|
+
throw new Error(`${this.#profile.displayName} Session store is not a directory`);
|
|
23319
|
+
for await (const project of await opendir(root)) {
|
|
23320
|
+
signal.throwIfAborted();
|
|
23321
|
+
if (!project.isDirectory())
|
|
23322
|
+
continue;
|
|
23323
|
+
const projectDirectory = path7.join(root, project.name);
|
|
23324
|
+
const entries = await opendir(projectDirectory).catch((error51) => {
|
|
23325
|
+
if (isMissingFileError(error51))
|
|
23326
|
+
return null;
|
|
23327
|
+
throw error51;
|
|
23328
|
+
});
|
|
23329
|
+
if (!entries)
|
|
23330
|
+
continue;
|
|
23331
|
+
for await (const entry of entries) {
|
|
23332
|
+
signal.throwIfAborted();
|
|
23333
|
+
const nativeSessionId = entry.isFile() ? SESSION_FILE.exec(entry.name)?.[1] : void 0;
|
|
23334
|
+
if (!nativeSessionId)
|
|
23335
|
+
continue;
|
|
23336
|
+
const files = found.get(nativeSessionId) ?? [];
|
|
23337
|
+
files.push(path7.join(projectDirectory, entry.name));
|
|
23338
|
+
found.set(nativeSessionId, files);
|
|
23339
|
+
}
|
|
23340
|
+
}
|
|
23341
|
+
return found;
|
|
23342
|
+
}
|
|
23343
|
+
async #source(nativeSessionId, file2, active, signal) {
|
|
23344
|
+
signal.throwIfAborted();
|
|
23345
|
+
return readStableFiles([file2], async ([info]) => {
|
|
23346
|
+
if (!info?.isFile() || info.size === 0 || info.size > MAX_HISTORY_BYTES)
|
|
23347
|
+
return null;
|
|
23348
|
+
try {
|
|
23349
|
+
const facts = await readFacts(file2, signal);
|
|
23350
|
+
if (!facts)
|
|
23351
|
+
return null;
|
|
23352
|
+
const cwd = path7.resolve(facts.cwd);
|
|
23353
|
+
if (!(await stat2(cwd)).isDirectory())
|
|
23354
|
+
return null;
|
|
23355
|
+
const nativeRef = nativeSessionRefSchema.parse({
|
|
23356
|
+
harnessId: this.#profile.harnessId,
|
|
23357
|
+
nativeSessionId,
|
|
23358
|
+
formatVersion: 1
|
|
23359
|
+
});
|
|
23360
|
+
signal.throwIfAborted();
|
|
23361
|
+
const history = await codeBuddyNativeHistory(cwd, nativeRef, this.#environment, this.#profile);
|
|
23362
|
+
if (path7.resolve(history.file) !== path7.resolve(file2))
|
|
23363
|
+
return null;
|
|
23364
|
+
const candidate = sessionImportCandidate({
|
|
23365
|
+
nativeSessionId,
|
|
23366
|
+
cwd,
|
|
23367
|
+
title: facts.title,
|
|
23368
|
+
updatedAt: facts.updatedAt ?? info.mtimeMs,
|
|
23369
|
+
// A registered live process holds the Session. Absence is not proof of idleness.
|
|
23370
|
+
running: active.has(nativeSessionId) ? true : null
|
|
23371
|
+
});
|
|
23372
|
+
return candidate ? { candidate, nativeRef } : null;
|
|
23373
|
+
} catch (error51) {
|
|
23374
|
+
signal.throwIfAborted();
|
|
23375
|
+
if (isStorageAccessError(error51))
|
|
23376
|
+
throw error51;
|
|
23377
|
+
return null;
|
|
23378
|
+
}
|
|
23379
|
+
});
|
|
23380
|
+
}
|
|
23381
|
+
};
|
|
23382
|
+
|
|
22963
23383
|
// dist/interactions.js
|
|
22964
23384
|
var CodeBuddyInteractions = class {
|
|
22965
23385
|
emit;
|
|
@@ -23103,7 +23523,7 @@ var CodeBuddyInteractions = class {
|
|
|
23103
23523
|
|
|
23104
23524
|
// dist/subagent-history.js
|
|
23105
23525
|
import { readdir as readdir2, realpath as realpath6 } from "node:fs/promises";
|
|
23106
|
-
import
|
|
23526
|
+
import path8 from "node:path";
|
|
23107
23527
|
var equalPath2 = (a, b) => process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
23108
23528
|
var MAX_CACHED_CHILDREN = 16;
|
|
23109
23529
|
var CodeBuddyChildObserver = class {
|
|
@@ -23167,8 +23587,8 @@ var CodeBuddyChildObserver = class {
|
|
|
23167
23587
|
}
|
|
23168
23588
|
async #directory() {
|
|
23169
23589
|
const history = await this.#parentHistory();
|
|
23170
|
-
const project =
|
|
23171
|
-
const expected =
|
|
23590
|
+
const project = path8.dirname(await realpath6(history.file));
|
|
23591
|
+
const expected = path8.join(project, this.parent.nativeSessionId, "subagents");
|
|
23172
23592
|
const actual = await realpath6(expected);
|
|
23173
23593
|
this.#assertOpen();
|
|
23174
23594
|
if (!equalPath2(actual, expected))
|
|
@@ -23178,7 +23598,7 @@ var CodeBuddyChildObserver = class {
|
|
|
23178
23598
|
async #child(directory, childId) {
|
|
23179
23599
|
if (!validCodeBuddyChildId(childId))
|
|
23180
23600
|
throw new CodeBuddyError("invalidRequest", "Invalid native Subagent ID");
|
|
23181
|
-
const file2 =
|
|
23601
|
+
const file2 = path8.join(directory, `${childId}.jsonl`);
|
|
23182
23602
|
const before = await codeBuddyFileVersion(file2);
|
|
23183
23603
|
if (!equalPath2(before.realFile, file2))
|
|
23184
23604
|
throw new CodeBuddyError("invalidRequest", "Redirected Subagent transcript");
|
|
@@ -23891,6 +24311,7 @@ var CodeBuddyAdapter = class {
|
|
|
23891
24311
|
harnessId;
|
|
23892
24312
|
commandCatalog;
|
|
23893
24313
|
liveCommandCatalog = true;
|
|
24314
|
+
sessionImport;
|
|
23894
24315
|
subagents = {
|
|
23895
24316
|
readSnapshot: async ({ parent, nativeSubagentId, cwd }) => {
|
|
23896
24317
|
try {
|
|
@@ -23924,6 +24345,7 @@ var CodeBuddyAdapter = class {
|
|
|
23924
24345
|
this.commandCatalog = commandCatalog2;
|
|
23925
24346
|
}
|
|
23926
24347
|
this.#environment = { ...options.environment ?? process.env };
|
|
24348
|
+
this.sessionImport = new CodeBuddySessionImport(this.#environment, this.#profile);
|
|
23927
24349
|
this.#invocation = options.invocationFactory ?? codeBuddyInvocation;
|
|
23928
24350
|
this.#factory = options.clientFactory ?? ((clientOptions) => new CodeBuddyAcpClient(clientOptions, void 0, this.#invocation));
|
|
23929
24351
|
}
|
|
@@ -23943,7 +24365,7 @@ var CodeBuddyAdapter = class {
|
|
|
23943
24365
|
try {
|
|
23944
24366
|
if (this.#closed)
|
|
23945
24367
|
throw new CodeBuddyError("invalidState", "Adapter is closed");
|
|
23946
|
-
if (!(await
|
|
24368
|
+
if (!(await stat3(cwd)).isDirectory())
|
|
23947
24369
|
throw new CodeBuddyError("invalidRequest", "Working directory is not a directory");
|
|
23948
24370
|
client2 = this.#factory({
|
|
23949
24371
|
cwd,
|
|
@@ -23989,7 +24411,7 @@ var CodeBuddyAdapter = class {
|
|
|
23989
24411
|
return failure("invalidRequest", "Unattended execution requires native fullAccess permissions", this.#profile);
|
|
23990
24412
|
let session;
|
|
23991
24413
|
try {
|
|
23992
|
-
if (!(await
|
|
24414
|
+
if (!(await stat3(input.cwd)).isDirectory())
|
|
23993
24415
|
throw new CodeBuddyError("invalidRequest", "Working directory is not a directory");
|
|
23994
24416
|
if (this.#closed)
|
|
23995
24417
|
throw new CodeBuddyError("invalidState", "Adapter closed while opening Session");
|
|
@@ -24052,7 +24474,7 @@ var CodeBuddyAdapter = class {
|
|
|
24052
24474
|
async close() {
|
|
24053
24475
|
this.#closed = true;
|
|
24054
24476
|
this.#abort.abort();
|
|
24055
|
-
await Promise.allSettled([...this.#derivations]);
|
|
24477
|
+
await Promise.allSettled([this.sessionImport.close(), ...this.#derivations]);
|
|
24056
24478
|
const results = await Promise.allSettled([...this.#sessions, ...this.#inspections].map((resource) => resource.close()));
|
|
24057
24479
|
this.#sessions.clear();
|
|
24058
24480
|
this.#inspections.clear();
|
|
@@ -24096,8 +24518,9 @@ function createCodeBuddyInstallation(environment) {
|
|
|
24096
24518
|
}
|
|
24097
24519
|
|
|
24098
24520
|
// ../../harness-broker/dist/client.js
|
|
24521
|
+
import { execFile as execFile4 } from "node:child_process";
|
|
24099
24522
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
24100
|
-
import { lstat as
|
|
24523
|
+
import { lstat as lstat3, readFile as readFile5 } from "node:fs/promises";
|
|
24101
24524
|
import net, {} from "node:net";
|
|
24102
24525
|
|
|
24103
24526
|
// ../../harness-broker/dist/protocol.js
|
|
@@ -24106,9 +24529,12 @@ var HARNESS_BROKER_MAX_FRAME_BYTES = 8 * 1024 * 1024;
|
|
|
24106
24529
|
var HARNESS_BROKER_MAX_PENDING_REQUESTS = 32;
|
|
24107
24530
|
var HARNESS_BROKER_REQUEST_TIMEOUT_MS = 15e3;
|
|
24108
24531
|
var HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE = 100;
|
|
24532
|
+
var HARNESS_BROKER_IDLE_TIMEOUT_MS = 60 * 60 * 1e3;
|
|
24533
|
+
var HARNESS_BROKER_RETIRING_ERROR_CODE = "brokerRetiring";
|
|
24109
24534
|
var harnessBrokerMethodSchema = external_exports.enum([
|
|
24110
24535
|
"adapter.inspect",
|
|
24111
24536
|
"adapter.inspectAccount",
|
|
24537
|
+
"adapter.credits",
|
|
24112
24538
|
"adapter.open",
|
|
24113
24539
|
"adapter.sessionImport.list",
|
|
24114
24540
|
"adapter.sessionImport.resolve",
|
|
@@ -24215,18 +24641,26 @@ function consumeBrokerFrames(socket, onFrame, onError) {
|
|
|
24215
24641
|
|
|
24216
24642
|
// ../../harness-broker/dist/paths.js
|
|
24217
24643
|
import os2 from "node:os";
|
|
24218
|
-
import
|
|
24644
|
+
import path9 from "node:path";
|
|
24219
24645
|
var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
|
|
24220
24646
|
var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
|
|
24221
24647
|
function defaultHarnessBrokerDirectory(environment = process.env) {
|
|
24222
24648
|
const home = environment.HOME || os2.homedir();
|
|
24223
|
-
return
|
|
24649
|
+
return path9.join(home, ".codexhost", "harness-broker");
|
|
24224
24650
|
}
|
|
24225
24651
|
function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
|
|
24226
24652
|
harnessPluginIdSchema.parse(harnessId);
|
|
24227
24653
|
if (harnessId !== "claude-code")
|
|
24228
|
-
return
|
|
24229
|
-
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ??
|
|
24654
|
+
return path9.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
|
|
24655
|
+
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path9.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
|
|
24656
|
+
}
|
|
24657
|
+
function harnessBrokerLaunchAgentLabel(harnessId = "claude-code") {
|
|
24658
|
+
harnessPluginIdSchema.parse(harnessId);
|
|
24659
|
+
return harnessId === "claude-code" ? "ai.bytepioneer.codexhost.native-harness-broker" : `ai.bytepioneer.codexhost.${harnessId}-broker`;
|
|
24660
|
+
}
|
|
24661
|
+
function harnessBrokerLaunchAgentPlistPath(environment = process.env, harnessId = "claude-code") {
|
|
24662
|
+
const home = environment.HOME || os2.homedir();
|
|
24663
|
+
return path9.join(home, "Library", "LaunchAgents", `${harnessBrokerLaunchAgentLabel(harnessId)}.plist`);
|
|
24230
24664
|
}
|
|
24231
24665
|
|
|
24232
24666
|
// ../../harness-broker/dist/validation.js
|
|
@@ -24526,7 +24960,7 @@ function parseSessionMetadata(value) {
|
|
|
24526
24960
|
};
|
|
24527
24961
|
}
|
|
24528
24962
|
async function readDescriptor(descriptorPath) {
|
|
24529
|
-
const metadata = await
|
|
24963
|
+
const metadata = await lstat3(descriptorPath);
|
|
24530
24964
|
if (metadata.isSymbolicLink())
|
|
24531
24965
|
throw new Error("Aqua Harness broker descriptor must not be a symlink");
|
|
24532
24966
|
if (!metadata.isFile())
|
|
@@ -24538,12 +24972,12 @@ async function readDescriptor(descriptorPath) {
|
|
|
24538
24972
|
throw new Error("Aqua Harness broker descriptor belongs to another user");
|
|
24539
24973
|
}
|
|
24540
24974
|
}
|
|
24541
|
-
const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await
|
|
24975
|
+
const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await readFile5(descriptorPath, "utf8")));
|
|
24542
24976
|
if (process.platform === "darwin" && Buffer.byteLength(descriptor.socketPath) > 103) {
|
|
24543
24977
|
throw new Error("Aqua Harness broker socket path is too long for macOS");
|
|
24544
24978
|
}
|
|
24545
24979
|
if (process.platform !== "win32") {
|
|
24546
|
-
const socket = await
|
|
24980
|
+
const socket = await lstat3(descriptor.socketPath);
|
|
24547
24981
|
if (socket.isSymbolicLink() || !socket.isSocket()) {
|
|
24548
24982
|
throw new Error("Aqua Harness broker endpoint is not a Unix socket");
|
|
24549
24983
|
}
|
|
@@ -24554,10 +24988,55 @@ async function readDescriptor(descriptorPath) {
|
|
|
24554
24988
|
try {
|
|
24555
24989
|
process.kill(descriptor.ownerPid, 0);
|
|
24556
24990
|
} catch {
|
|
24557
|
-
throw new
|
|
24991
|
+
throw new BrokerNotRunningError("its owner process has exited");
|
|
24558
24992
|
}
|
|
24559
24993
|
return descriptor;
|
|
24560
24994
|
}
|
|
24995
|
+
var BrokerNotRunningError = class extends Error {
|
|
24996
|
+
};
|
|
24997
|
+
var BrokerRetiringError = class extends Error {
|
|
24998
|
+
};
|
|
24999
|
+
var BrokerRequestNotDeliveredError = class extends Error {
|
|
25000
|
+
};
|
|
25001
|
+
var HarnessNotInstalledError = class extends Error {
|
|
25002
|
+
};
|
|
25003
|
+
var BROKER_NOT_RUNNING_CODES = /* @__PURE__ */ new Set(["ENOENT", "ECONNREFUSED"]);
|
|
25004
|
+
var BROKER_START_TIMEOUT_MS = 15e3;
|
|
25005
|
+
var BROKER_START_POLL_MS = 250;
|
|
25006
|
+
function classifyConnectFailure(error51) {
|
|
25007
|
+
if (error51 instanceof BrokerNotRunningError)
|
|
25008
|
+
return error51;
|
|
25009
|
+
const code = error51?.code;
|
|
25010
|
+
if (code && BROKER_NOT_RUNNING_CODES.has(code)) {
|
|
25011
|
+
return new BrokerNotRunningError(code === "ENOENT" ? "its descriptor or socket is missing" : "its socket refused the connection");
|
|
25012
|
+
}
|
|
25013
|
+
return error51 instanceof Error ? error51 : new Error(String(error51));
|
|
25014
|
+
}
|
|
25015
|
+
function describeBrokerFailure(error51, harnessId) {
|
|
25016
|
+
if (error51 instanceof BrokerNotRunningError) {
|
|
25017
|
+
return `The ${harnessId} Aqua Harness broker on this Mac could not be started (${error51.message}). Keep the desktop user logged in, then repair the remote service or run on this Mac: codexhost broker install --harness ${harnessId}`;
|
|
25018
|
+
}
|
|
25019
|
+
return error51 instanceof Error ? error51.message : String(error51);
|
|
25020
|
+
}
|
|
25021
|
+
function runLaunchctl(arguments_) {
|
|
25022
|
+
return new Promise((resolve) => {
|
|
25023
|
+
execFile4("/bin/launchctl", arguments_, { timeout: 1e4 }, (error51) => resolve(!error51));
|
|
25024
|
+
});
|
|
25025
|
+
}
|
|
25026
|
+
async function startBrokerLaunchAgent(harnessId, environment) {
|
|
25027
|
+
const uid = process.getuid?.();
|
|
25028
|
+
if (uid === void 0)
|
|
25029
|
+
return;
|
|
25030
|
+
const target = `gui/${uid}/${harnessBrokerLaunchAgentLabel(harnessId)}`;
|
|
25031
|
+
if (await runLaunchctl(["kickstart", target]))
|
|
25032
|
+
return;
|
|
25033
|
+
await runLaunchctl([
|
|
25034
|
+
"bootstrap",
|
|
25035
|
+
`gui/${uid}`,
|
|
25036
|
+
harnessBrokerLaunchAgentPlistPath(environment, harnessId)
|
|
25037
|
+
]);
|
|
25038
|
+
await runLaunchctl(["kickstart", target]);
|
|
25039
|
+
}
|
|
24561
25040
|
var BrokerConnection = class _BrokerConnection {
|
|
24562
25041
|
#onClose;
|
|
24563
25042
|
onClose(callback) {
|
|
@@ -24581,21 +25060,31 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
24581
25060
|
socket.once("error", (error51) => this.#fail(error51));
|
|
24582
25061
|
}
|
|
24583
25062
|
static async connect(descriptorPath, harnessId) {
|
|
24584
|
-
|
|
24585
|
-
|
|
24586
|
-
|
|
24587
|
-
|
|
24588
|
-
|
|
24589
|
-
|
|
24590
|
-
|
|
24591
|
-
|
|
24592
|
-
|
|
24593
|
-
|
|
24594
|
-
|
|
24595
|
-
|
|
24596
|
-
|
|
25063
|
+
let descriptor;
|
|
25064
|
+
let socket;
|
|
25065
|
+
let connecting;
|
|
25066
|
+
try {
|
|
25067
|
+
descriptor = await readDescriptor(descriptorPath);
|
|
25068
|
+
if (descriptor.harnessId !== harnessId)
|
|
25069
|
+
throw new Error("Aqua broker belongs to another Harness");
|
|
25070
|
+
connecting = net.createConnection(descriptor.socketPath);
|
|
25071
|
+
const pending = connecting;
|
|
25072
|
+
await new Promise((resolve, reject) => {
|
|
25073
|
+
const timeout = setTimeout(() => reject(new Error("Timed out connecting to Aqua Harness broker")), HARNESS_BROKER_REQUEST_TIMEOUT_MS);
|
|
25074
|
+
pending.once("connect", () => {
|
|
25075
|
+
clearTimeout(timeout);
|
|
25076
|
+
resolve();
|
|
25077
|
+
});
|
|
25078
|
+
pending.once("error", (error51) => {
|
|
25079
|
+
clearTimeout(timeout);
|
|
25080
|
+
reject(error51);
|
|
25081
|
+
});
|
|
24597
25082
|
});
|
|
24598
|
-
|
|
25083
|
+
socket = pending;
|
|
25084
|
+
} catch (error51) {
|
|
25085
|
+
connecting?.destroy();
|
|
25086
|
+
throw classifyConnectFailure(error51);
|
|
25087
|
+
}
|
|
24599
25088
|
const connection = new _BrokerConnection(descriptor, socket);
|
|
24600
25089
|
const hello = connection.#waitForHello();
|
|
24601
25090
|
await writeBrokerFrame(socket, {
|
|
@@ -24648,15 +25137,24 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
24648
25137
|
}, HARNESS_BROKER_REQUEST_TIMEOUT_MS);
|
|
24649
25138
|
this.#pending.set(id, { resolve, reject, timeout });
|
|
24650
25139
|
});
|
|
24651
|
-
|
|
24652
|
-
|
|
24653
|
-
|
|
24654
|
-
|
|
24655
|
-
|
|
24656
|
-
|
|
24657
|
-
|
|
24658
|
-
|
|
24659
|
-
|
|
25140
|
+
try {
|
|
25141
|
+
await writeBrokerFrame(this.#socket, {
|
|
25142
|
+
version: HARNESS_BROKER_PROTOCOL_VERSION,
|
|
25143
|
+
generation: this.#descriptor.generation,
|
|
25144
|
+
sequence: this.#inputSequence,
|
|
25145
|
+
kind: "request",
|
|
25146
|
+
id,
|
|
25147
|
+
method,
|
|
25148
|
+
params
|
|
25149
|
+
});
|
|
25150
|
+
} catch (error51) {
|
|
25151
|
+
const pending = this.#pending.get(id);
|
|
25152
|
+
if (pending)
|
|
25153
|
+
clearTimeout(pending.timeout);
|
|
25154
|
+
this.#pending.delete(id);
|
|
25155
|
+
response.catch(() => void 0);
|
|
25156
|
+
throw new BrokerRequestNotDeliveredError(error51 instanceof Error ? error51.message : String(error51));
|
|
25157
|
+
}
|
|
24660
25158
|
return response;
|
|
24661
25159
|
}
|
|
24662
25160
|
close() {
|
|
@@ -24700,6 +25198,8 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
24700
25198
|
this.#pending.delete(frame.id);
|
|
24701
25199
|
if (frame.ok)
|
|
24702
25200
|
pending.resolve(frame.value);
|
|
25201
|
+
else if (frame.error?.code === HARNESS_BROKER_RETIRING_ERROR_CODE)
|
|
25202
|
+
pending.reject(new BrokerRetiringError(frame.error.message));
|
|
24703
25203
|
else
|
|
24704
25204
|
pending.reject(new Error(frame.error?.message ?? "Broker request failed"));
|
|
24705
25205
|
}
|
|
@@ -24925,18 +25425,20 @@ var BrokeredHarnessAdapter = class {
|
|
|
24925
25425
|
harnessId;
|
|
24926
25426
|
#descriptorPath;
|
|
24927
25427
|
#forwardEnvironment;
|
|
25428
|
+
#isInstalled;
|
|
25429
|
+
#startBroker;
|
|
25430
|
+
#startTimeoutMs;
|
|
24928
25431
|
#connection = null;
|
|
24929
25432
|
#closed = false;
|
|
24930
25433
|
#sessionImportListing = null;
|
|
25434
|
+
#credits = null;
|
|
25435
|
+
#creditsRefresh = null;
|
|
24931
25436
|
subagents = {
|
|
24932
25437
|
readSnapshot: async (input) => {
|
|
24933
25438
|
try {
|
|
24934
|
-
return parseHarnessResult(await
|
|
25439
|
+
return parseHarnessResult(await this.#request("adapter.subagent.readSnapshot", input));
|
|
24935
25440
|
} catch (error51) {
|
|
24936
|
-
return {
|
|
24937
|
-
ok: false,
|
|
24938
|
-
error: unavailable(error51 instanceof Error ? error51.message : String(error51))
|
|
24939
|
-
};
|
|
25441
|
+
return { ok: false, error: this.#error(error51) };
|
|
24940
25442
|
}
|
|
24941
25443
|
}
|
|
24942
25444
|
};
|
|
@@ -25026,12 +25528,39 @@ var BrokeredHarnessAdapter = class {
|
|
|
25026
25528
|
if (input.liveCommandCatalog)
|
|
25027
25529
|
this.liveCommandCatalog = true;
|
|
25028
25530
|
this.#descriptorPath = input.descriptorPath ?? defaultHarnessBrokerDescriptorPath(input.environment, this.harnessId);
|
|
25531
|
+
this.#isInstalled = input.isInstalled;
|
|
25532
|
+
const environment = input.environment ?? process.env;
|
|
25533
|
+
this.#startBroker = input.startBroker === false ? void 0 : input.startBroker ?? (process.platform === "darwin" && !input.descriptorPath ? () => startBrokerLaunchAgent(this.harnessId, environment) : void 0);
|
|
25534
|
+
this.#startTimeoutMs = input.startTimeoutMs ?? BROKER_START_TIMEOUT_MS;
|
|
25535
|
+
}
|
|
25536
|
+
credits() {
|
|
25537
|
+
return this.#credits;
|
|
25538
|
+
}
|
|
25539
|
+
refreshCredits() {
|
|
25540
|
+
if (this.#closed)
|
|
25541
|
+
return Promise.resolve(null);
|
|
25542
|
+
if (this.#creditsRefresh)
|
|
25543
|
+
return this.#creditsRefresh;
|
|
25544
|
+
this.#creditsRefresh = this.#readCredits().finally(() => {
|
|
25545
|
+
this.#creditsRefresh = null;
|
|
25546
|
+
});
|
|
25547
|
+
return this.#creditsRefresh;
|
|
25548
|
+
}
|
|
25549
|
+
async #readCredits() {
|
|
25550
|
+
try {
|
|
25551
|
+
const value = await this.#request("adapter.credits", {}, true);
|
|
25552
|
+
const credits = accountCreditsSnapshotSchema.nullable().parse(value);
|
|
25553
|
+
if (!this.#closed)
|
|
25554
|
+
this.#credits = credits;
|
|
25555
|
+
} catch {
|
|
25556
|
+
}
|
|
25557
|
+
return this.#credits;
|
|
25029
25558
|
}
|
|
25030
25559
|
async inspectAccount() {
|
|
25031
25560
|
if (this.#closed)
|
|
25032
25561
|
return null;
|
|
25033
25562
|
try {
|
|
25034
|
-
const value = await
|
|
25563
|
+
const value = await this.#request("adapter.inspectAccount", {}, true);
|
|
25035
25564
|
return harnessAccountSnapshotSchema.nullable().parse(value);
|
|
25036
25565
|
} catch {
|
|
25037
25566
|
return null;
|
|
@@ -25041,33 +25570,46 @@ var BrokeredHarnessAdapter = class {
|
|
|
25041
25570
|
if (this.#closed)
|
|
25042
25571
|
return failedInspection("Aqua Harness broker adapter is closed");
|
|
25043
25572
|
try {
|
|
25044
|
-
return harnessInspectionSchema.parse(await
|
|
25573
|
+
return harnessInspectionSchema.parse(await this.#request("adapter.inspect", input, true));
|
|
25045
25574
|
} catch (error51) {
|
|
25046
25575
|
this.#connection = null;
|
|
25047
|
-
|
|
25576
|
+
if (error51 instanceof HarnessNotInstalledError)
|
|
25577
|
+
return { status: "notInstalled", error: this.#error(error51) };
|
|
25578
|
+
return failedInspection(describeBrokerFailure(error51, this.harnessId));
|
|
25048
25579
|
}
|
|
25049
25580
|
}
|
|
25050
25581
|
async open(input) {
|
|
25051
25582
|
if (this.#closed)
|
|
25052
25583
|
return { ok: false, error: unavailable("Aqua Harness broker adapter is closed", false) };
|
|
25584
|
+
const safeInput = { ...input };
|
|
25585
|
+
delete safeInput.environment;
|
|
25586
|
+
if (this.#forwardEnvironment && input.environment) {
|
|
25587
|
+
const allowed = [
|
|
25588
|
+
"CODEXHOST_CLI_PATH",
|
|
25589
|
+
"CODEXHOST_CLI_NODE_PATH",
|
|
25590
|
+
"CODEXHOST_RUNTIME_ENDPOINT",
|
|
25591
|
+
"CODEXHOST_RUNTIME_TOKEN",
|
|
25592
|
+
"CODEXHOST_THREAD_ID"
|
|
25593
|
+
];
|
|
25594
|
+
const environment = Object.fromEntries(Object.entries(input.environment).filter(([key, value]) => allowed.includes(key) && value !== void 0));
|
|
25595
|
+
if (Object.keys(environment).length)
|
|
25596
|
+
safeInput.environment = environment;
|
|
25597
|
+
}
|
|
25053
25598
|
let connection;
|
|
25054
25599
|
try {
|
|
25055
|
-
|
|
25056
|
-
|
|
25057
|
-
|
|
25058
|
-
|
|
25059
|
-
"
|
|
25060
|
-
|
|
25061
|
-
|
|
25062
|
-
|
|
25063
|
-
|
|
25064
|
-
|
|
25065
|
-
|
|
25066
|
-
|
|
25067
|
-
|
|
25068
|
-
}
|
|
25069
|
-
connection = await this.#connect();
|
|
25070
|
-
const result = parseHarnessResult(await connection.request("adapter.open", safeInput));
|
|
25600
|
+
let value;
|
|
25601
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
25602
|
+
connection = await this.#connect();
|
|
25603
|
+
try {
|
|
25604
|
+
value = await connection.request("adapter.open", safeInput);
|
|
25605
|
+
break;
|
|
25606
|
+
} catch (error51) {
|
|
25607
|
+
if (attempt > 0 || !(error51 instanceof BrokerRetiringError || error51 instanceof BrokerRequestNotDeliveredError))
|
|
25608
|
+
throw error51;
|
|
25609
|
+
this.#connection = null;
|
|
25610
|
+
}
|
|
25611
|
+
}
|
|
25612
|
+
const result = parseHarnessResult(value);
|
|
25071
25613
|
if (!result.ok)
|
|
25072
25614
|
return result;
|
|
25073
25615
|
const session = new BrokeredHarnessSession(connection, parseSessionMetadata(result.value), this.harnessId, safeInput, () => this.#connect(), () => {
|
|
@@ -25078,25 +25620,51 @@ var BrokeredHarnessAdapter = class {
|
|
|
25078
25620
|
} catch (error51) {
|
|
25079
25621
|
connection?.close();
|
|
25080
25622
|
this.#connection = null;
|
|
25081
|
-
return {
|
|
25082
|
-
ok: false,
|
|
25083
|
-
error: unavailable(error51 instanceof Error ? error51.message : String(error51))
|
|
25084
|
-
};
|
|
25623
|
+
return { ok: false, error: this.#error(error51) };
|
|
25085
25624
|
}
|
|
25086
25625
|
}
|
|
25087
25626
|
async close() {
|
|
25088
25627
|
this.#closed = true;
|
|
25628
|
+
this.#credits = null;
|
|
25089
25629
|
await Promise.allSettled([...this.#sessions].map((session) => session.close()));
|
|
25090
25630
|
this.#sessions.clear();
|
|
25091
25631
|
const connection = await this.#connection?.catch(() => null);
|
|
25092
25632
|
await connection?.dispose();
|
|
25093
25633
|
this.#connection = null;
|
|
25094
25634
|
}
|
|
25635
|
+
#error(error51) {
|
|
25636
|
+
if (error51 instanceof HarnessNotInstalledError)
|
|
25637
|
+
return {
|
|
25638
|
+
code: "notInstalled",
|
|
25639
|
+
message: error51.message,
|
|
25640
|
+
retryable: false,
|
|
25641
|
+
stage: "harnessBroker"
|
|
25642
|
+
};
|
|
25643
|
+
return unavailable(describeBrokerFailure(error51, this.harnessId));
|
|
25644
|
+
}
|
|
25645
|
+
/**
|
|
25646
|
+
* Sends one adapter-level request. A broker that retired between requests refuses it
|
|
25647
|
+
* unprocessed, so it is retried once on a fresh broker. Idempotent reads also retry
|
|
25648
|
+
* once after a plain disconnect.
|
|
25649
|
+
*/
|
|
25650
|
+
async #request(method, params, idempotent = false) {
|
|
25651
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
25652
|
+
const connection = await this.#connect();
|
|
25653
|
+
try {
|
|
25654
|
+
return await connection.request(method, params);
|
|
25655
|
+
} catch (error51) {
|
|
25656
|
+
const retryable = error51 instanceof BrokerRetiringError || error51 instanceof BrokerRequestNotDeliveredError || idempotent && connection.closed;
|
|
25657
|
+
if (attempt > 0 || !retryable)
|
|
25658
|
+
throw error51;
|
|
25659
|
+
this.#connection = null;
|
|
25660
|
+
}
|
|
25661
|
+
}
|
|
25662
|
+
}
|
|
25095
25663
|
#connect() {
|
|
25096
25664
|
if (this.#closed)
|
|
25097
25665
|
return Promise.reject(new Error("Aqua Harness broker adapter is closed"));
|
|
25098
25666
|
if (!this.#connection) {
|
|
25099
|
-
const pending =
|
|
25667
|
+
const pending = this.#establish().then((connection) => {
|
|
25100
25668
|
connection.onClose(() => {
|
|
25101
25669
|
if (this.#connection === pending)
|
|
25102
25670
|
this.#connection = null;
|
|
@@ -25111,18 +25679,43 @@ var BrokeredHarnessAdapter = class {
|
|
|
25111
25679
|
}
|
|
25112
25680
|
return this.#connection;
|
|
25113
25681
|
}
|
|
25682
|
+
async #establish() {
|
|
25683
|
+
try {
|
|
25684
|
+
return await BrokerConnection.connect(this.#descriptorPath, this.harnessId);
|
|
25685
|
+
} catch (error51) {
|
|
25686
|
+
if (!(error51 instanceof BrokerNotRunningError) || !this.#startBroker)
|
|
25687
|
+
throw error51;
|
|
25688
|
+
}
|
|
25689
|
+
if (this.#isInstalled && !this.#isInstalled()) {
|
|
25690
|
+
throw new HarnessNotInstalledError(`${this.harnessId} is not installed on this Mac`);
|
|
25691
|
+
}
|
|
25692
|
+
const deadline = Date.now() + this.#startTimeoutMs;
|
|
25693
|
+
for (; ; ) {
|
|
25694
|
+
await this.#startBroker();
|
|
25695
|
+
try {
|
|
25696
|
+
return await BrokerConnection.connect(this.#descriptorPath, this.harnessId);
|
|
25697
|
+
} catch (error51) {
|
|
25698
|
+
if (!(error51 instanceof BrokerNotRunningError) || Date.now() >= deadline)
|
|
25699
|
+
throw error51;
|
|
25700
|
+
}
|
|
25701
|
+
await new Promise((resolve) => setTimeout(resolve, BROKER_START_POLL_MS));
|
|
25702
|
+
}
|
|
25703
|
+
}
|
|
25114
25704
|
};
|
|
25115
25705
|
|
|
25116
25706
|
// dist/plugin.js
|
|
25117
25707
|
function createHarnessAdapter(context) {
|
|
25118
|
-
if (context.platform === "darwin" && context.managedRemoteHost)
|
|
25708
|
+
if (context.platform === "darwin" && context.managedRemoteHost) {
|
|
25709
|
+
const environment2 = { ...context.environment };
|
|
25119
25710
|
return new BrokeredHarnessAdapter({
|
|
25120
25711
|
harnessId: "codebuddy",
|
|
25121
25712
|
forwardDelegationEnvironment: true,
|
|
25122
25713
|
commandCatalog: CODEBUDDY_COMMAND_CATALOG,
|
|
25123
25714
|
liveCommandCatalog: true,
|
|
25124
|
-
environment:
|
|
25715
|
+
environment: environment2,
|
|
25716
|
+
isInstalled: () => resolveHarnessExecutable(codeBuddyDiscoverySpec, { environment: environment2 }) !== void 0
|
|
25125
25717
|
});
|
|
25718
|
+
}
|
|
25126
25719
|
const environment = { ...context.environment };
|
|
25127
25720
|
return Object.assign(new CodeBuddyAdapter({ environment }), {
|
|
25128
25721
|
installation: createCodeBuddyInstallation(environment),
|