@liberseek/boft-cli-win32-arm64 0.7.7 → 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 +16598 -16440
- package/app/console-web.js +3628 -1789
- package/app/desktop-controller.mjs +16256 -351
- package/app/host-runtime.mjs +4360 -962
- package/app/plugins/antigravity/plugin.mjs +86 -2
- package/app/plugins/claude-code/plugin.mjs +399 -102
- package/app/plugins/codebuddy/plugin.mjs +733 -136
- package/app/plugins/cursor-cli/plugin.mjs +436 -122
- package/app/plugins/deepseek-harness/plugin.mjs +87 -2
- package/app/plugins/enabled.json +2 -1
- package/app/plugins/grok/plugin.mjs +464 -58
- package/app/plugins/hermes/plugin.mjs +3307 -7685
- package/app/plugins/kimi-code/plugin.mjs +376 -43
- package/app/plugins/kiro-cli/plugin.mjs +390 -48
- package/app/plugins/muse/plugin.mjs +86 -2
- package/app/plugins/omp/plugin.mjs +539 -105
- package/app/plugins/opencode/plugin.mjs +333 -79
- package/app/plugins/pi/plugin.mjs +200 -57
- package/app/plugins/qoder/plugin.mjs +317 -38
- package/app/plugins/qoder-cn/plugin.mjs +317 -38
- package/app/plugins/workbuddy/plugin.mjs +704 -98
- 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 +2766 -695
- 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 +2 -2
|
@@ -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",
|
|
@@ -15776,7 +15783,10 @@ var harnessInstallationStateSchema = external_exports.object({
|
|
|
15776
15783
|
latestVersion: external_exports.string().min(1).max(128),
|
|
15777
15784
|
updateAvailable: external_exports.boolean(),
|
|
15778
15785
|
canUpdate: external_exports.boolean(),
|
|
15779
|
-
|
|
15786
|
+
// Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
|
|
15787
|
+
message: external_exports.string().max(2048).optional(),
|
|
15788
|
+
messageCode: external_exports.string().min(1).max(128).optional(),
|
|
15789
|
+
latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
|
|
15780
15790
|
}).strict();
|
|
15781
15791
|
|
|
15782
15792
|
// ../../shared-contracts/dist/codex-accounts.js
|
|
@@ -16071,7 +16081,7 @@ var updateStatusSchema = external_exports.strictObject({
|
|
|
16071
16081
|
}
|
|
16072
16082
|
});
|
|
16073
16083
|
var updateEmptyParamsSchema = external_exports.strictObject({});
|
|
16074
|
-
var githubReleaseNotesUrlSchema = external_exports.string().max(300).regex(/^https:\/\/github\.com\/LiberSeek\/BOFT-CLI\/releases\/tag\/v[0-9A-Za-z.+-]+$/u, "release notes URL must identify a codexhost GitHub Release");
|
|
16084
|
+
var githubReleaseNotesUrlSchema = external_exports.string().max(300).regex(/^https:\/\/github\.com\/(LiberSeek|LIBERSEEK)\/BOFT-CLI\/releases\/tag\/v[0-9A-Za-z.+-]+$/u, "release notes URL must identify a codexhost GitHub Release");
|
|
16075
16085
|
var updateCheckResultSchema = external_exports.strictObject({
|
|
16076
16086
|
currentVersion: updateSemanticVersionSchema,
|
|
16077
16087
|
installation: updateInstallationSchema.nullable(),
|
|
@@ -16090,6 +16100,80 @@ var updateStatusResultSchema = external_exports.strictObject({
|
|
|
16090
16100
|
status: updateStatusSchema.nullable()
|
|
16091
16101
|
});
|
|
16092
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
|
+
|
|
16093
16177
|
// ../../shared-contracts/dist/index.js
|
|
16094
16178
|
var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
|
|
16095
16179
|
|
|
@@ -16438,6 +16522,44 @@ async function bounded(operation, milliseconds, label, onTimeout) {
|
|
|
16438
16522
|
}
|
|
16439
16523
|
}
|
|
16440
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
|
+
|
|
16441
16563
|
// dist/slash-commands.js
|
|
16442
16564
|
var excluded = /* @__PURE__ */ new Set([
|
|
16443
16565
|
"background",
|
|
@@ -16516,7 +16638,7 @@ function commandPrompt(command, catalog, profile = CODEBUDDY_RUNTIME_PROFILE) {
|
|
|
16516
16638
|
}
|
|
16517
16639
|
|
|
16518
16640
|
// dist/codebuddy-adapter.js
|
|
16519
|
-
import { stat as
|
|
16641
|
+
import { stat as stat3 } from "node:fs/promises";
|
|
16520
16642
|
|
|
16521
16643
|
// dist/acp-client.js
|
|
16522
16644
|
import { execFile as execFile2, spawn } from "node:child_process";
|
|
@@ -20745,44 +20867,6 @@ var CodeBuddyCopyCleanup = class {
|
|
|
20745
20867
|
}
|
|
20746
20868
|
};
|
|
20747
20869
|
|
|
20748
|
-
// dist/command.js
|
|
20749
|
-
var codeBuddyDiscoverySpec = {
|
|
20750
|
-
id: "codebuddy",
|
|
20751
|
-
command: "codebuddy",
|
|
20752
|
-
commandEnvironmentVariable: "CODEXHOST_CODEBUDDY_COMMAND",
|
|
20753
|
-
installRoots: {
|
|
20754
|
-
windows: ["${APPDATA}/npm", "~/.local/bin", VERSION_MANAGER_ROOTS],
|
|
20755
|
-
posix: [
|
|
20756
|
-
"~/.local/bin",
|
|
20757
|
-
"~/.npm-global/bin",
|
|
20758
|
-
VERSION_MANAGER_ROOTS,
|
|
20759
|
-
"/opt/homebrew/bin",
|
|
20760
|
-
"/usr/local/bin"
|
|
20761
|
-
]
|
|
20762
|
-
}
|
|
20763
|
-
};
|
|
20764
|
-
function codeBuddyInvocation(environment, ephemeral, argumentsOverride) {
|
|
20765
|
-
const resolved = resolveHarnessExecutable(codeBuddyDiscoverySpec, { environment });
|
|
20766
|
-
if (!resolved)
|
|
20767
|
-
throw new CodeBuddyError("notInstalled", "CLI is not installed; run codebuddy and sign in first");
|
|
20768
|
-
const env = withNodeRuntimeOnPath(environment);
|
|
20769
|
-
return {
|
|
20770
|
-
...commandInvocation(resolved.executable, argumentsOverride ?? [
|
|
20771
|
-
"--acp",
|
|
20772
|
-
...ephemeral ? ["--no-session-persistence"] : [],
|
|
20773
|
-
...!ephemeral && [
|
|
20774
|
-
"CODEXHOST_CLI_PATH",
|
|
20775
|
-
"CODEXHOST_RUNTIME_ENDPOINT",
|
|
20776
|
-
"CODEXHOST_RUNTIME_TOKEN",
|
|
20777
|
-
"CODEXHOST_THREAD_ID"
|
|
20778
|
-
].every((key) => environment[key]) ? ["--append-system-prompt", CODEBUDDY_DELEGATION_INSTRUCTIONS] : []
|
|
20779
|
-
], env),
|
|
20780
|
-
environment: env
|
|
20781
|
-
};
|
|
20782
|
-
}
|
|
20783
|
-
var CODEBUDDY_DELEGATION_INSTRUCTIONS = `This Session runs inside codexhost.
|
|
20784
|
-
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.`;
|
|
20785
|
-
|
|
20786
20870
|
// dist/acp-client.js
|
|
20787
20871
|
var CodeBuddyAcpClient = class {
|
|
20788
20872
|
options;
|
|
@@ -21142,16 +21226,16 @@ var Diff = class {
|
|
|
21142
21226
|
}
|
|
21143
21227
|
}
|
|
21144
21228
|
}
|
|
21145
|
-
addToPath(
|
|
21146
|
-
const last =
|
|
21229
|
+
addToPath(path10, added, removed, oldPosInc, options) {
|
|
21230
|
+
const last = path10.lastComponent;
|
|
21147
21231
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
21148
21232
|
return {
|
|
21149
|
-
oldPos:
|
|
21233
|
+
oldPos: path10.oldPos + oldPosInc,
|
|
21150
21234
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
21151
21235
|
};
|
|
21152
21236
|
} else {
|
|
21153
21237
|
return {
|
|
21154
|
-
oldPos:
|
|
21238
|
+
oldPos: path10.oldPos + oldPosInc,
|
|
21155
21239
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
21156
21240
|
};
|
|
21157
21241
|
}
|
|
@@ -22957,6 +23041,345 @@ async function deriveCodeBuddySession(options) {
|
|
|
22957
23041
|
}
|
|
22958
23042
|
}
|
|
22959
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
|
+
|
|
22960
23383
|
// dist/interactions.js
|
|
22961
23384
|
var CodeBuddyInteractions = class {
|
|
22962
23385
|
emit;
|
|
@@ -23100,7 +23523,7 @@ var CodeBuddyInteractions = class {
|
|
|
23100
23523
|
|
|
23101
23524
|
// dist/subagent-history.js
|
|
23102
23525
|
import { readdir as readdir2, realpath as realpath6 } from "node:fs/promises";
|
|
23103
|
-
import
|
|
23526
|
+
import path8 from "node:path";
|
|
23104
23527
|
var equalPath2 = (a, b) => process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
23105
23528
|
var MAX_CACHED_CHILDREN = 16;
|
|
23106
23529
|
var CodeBuddyChildObserver = class {
|
|
@@ -23164,8 +23587,8 @@ var CodeBuddyChildObserver = class {
|
|
|
23164
23587
|
}
|
|
23165
23588
|
async #directory() {
|
|
23166
23589
|
const history = await this.#parentHistory();
|
|
23167
|
-
const project =
|
|
23168
|
-
const expected =
|
|
23590
|
+
const project = path8.dirname(await realpath6(history.file));
|
|
23591
|
+
const expected = path8.join(project, this.parent.nativeSessionId, "subagents");
|
|
23169
23592
|
const actual = await realpath6(expected);
|
|
23170
23593
|
this.#assertOpen();
|
|
23171
23594
|
if (!equalPath2(actual, expected))
|
|
@@ -23175,7 +23598,7 @@ var CodeBuddyChildObserver = class {
|
|
|
23175
23598
|
async #child(directory, childId) {
|
|
23176
23599
|
if (!validCodeBuddyChildId(childId))
|
|
23177
23600
|
throw new CodeBuddyError("invalidRequest", "Invalid native Subagent ID");
|
|
23178
|
-
const file2 =
|
|
23601
|
+
const file2 = path8.join(directory, `${childId}.jsonl`);
|
|
23179
23602
|
const before = await codeBuddyFileVersion(file2);
|
|
23180
23603
|
if (!equalPath2(before.realFile, file2))
|
|
23181
23604
|
throw new CodeBuddyError("invalidRequest", "Redirected Subagent transcript");
|
|
@@ -23888,6 +24311,7 @@ var CodeBuddyAdapter = class {
|
|
|
23888
24311
|
harnessId;
|
|
23889
24312
|
commandCatalog;
|
|
23890
24313
|
liveCommandCatalog = true;
|
|
24314
|
+
sessionImport;
|
|
23891
24315
|
subagents = {
|
|
23892
24316
|
readSnapshot: async ({ parent, nativeSubagentId, cwd }) => {
|
|
23893
24317
|
try {
|
|
@@ -23921,6 +24345,7 @@ var CodeBuddyAdapter = class {
|
|
|
23921
24345
|
this.commandCatalog = commandCatalog2;
|
|
23922
24346
|
}
|
|
23923
24347
|
this.#environment = { ...options.environment ?? process.env };
|
|
24348
|
+
this.sessionImport = new CodeBuddySessionImport(this.#environment, this.#profile);
|
|
23924
24349
|
this.#invocation = options.invocationFactory ?? codeBuddyInvocation;
|
|
23925
24350
|
this.#factory = options.clientFactory ?? ((clientOptions) => new CodeBuddyAcpClient(clientOptions, void 0, this.#invocation));
|
|
23926
24351
|
}
|
|
@@ -23940,7 +24365,7 @@ var CodeBuddyAdapter = class {
|
|
|
23940
24365
|
try {
|
|
23941
24366
|
if (this.#closed)
|
|
23942
24367
|
throw new CodeBuddyError("invalidState", "Adapter is closed");
|
|
23943
|
-
if (!(await
|
|
24368
|
+
if (!(await stat3(cwd)).isDirectory())
|
|
23944
24369
|
throw new CodeBuddyError("invalidRequest", "Working directory is not a directory");
|
|
23945
24370
|
client2 = this.#factory({
|
|
23946
24371
|
cwd,
|
|
@@ -23986,7 +24411,7 @@ var CodeBuddyAdapter = class {
|
|
|
23986
24411
|
return failure("invalidRequest", "Unattended execution requires native fullAccess permissions", this.#profile);
|
|
23987
24412
|
let session;
|
|
23988
24413
|
try {
|
|
23989
|
-
if (!(await
|
|
24414
|
+
if (!(await stat3(input.cwd)).isDirectory())
|
|
23990
24415
|
throw new CodeBuddyError("invalidRequest", "Working directory is not a directory");
|
|
23991
24416
|
if (this.#closed)
|
|
23992
24417
|
throw new CodeBuddyError("invalidState", "Adapter closed while opening Session");
|
|
@@ -24049,7 +24474,7 @@ var CodeBuddyAdapter = class {
|
|
|
24049
24474
|
async close() {
|
|
24050
24475
|
this.#closed = true;
|
|
24051
24476
|
this.#abort.abort();
|
|
24052
|
-
await Promise.allSettled([...this.#derivations]);
|
|
24477
|
+
await Promise.allSettled([this.sessionImport.close(), ...this.#derivations]);
|
|
24053
24478
|
const results = await Promise.allSettled([...this.#sessions, ...this.#inspections].map((resource) => resource.close()));
|
|
24054
24479
|
this.#sessions.clear();
|
|
24055
24480
|
this.#inspections.clear();
|
|
@@ -24079,6 +24504,7 @@ function createCodeBuddyInstallation(environment) {
|
|
|
24079
24504
|
updateAvailable: !!npm && newerInstallationVersion(currentVersion, latestVersion),
|
|
24080
24505
|
canUpdate,
|
|
24081
24506
|
...!canUpdate ? {
|
|
24507
|
+
messageCode: "codebuddy-npm-required",
|
|
24082
24508
|
message: "Use CodeBuddy's native updater or original package manager for this installation. Latest-version checks here require an identified npm installation."
|
|
24083
24509
|
} : {}
|
|
24084
24510
|
};
|
|
@@ -24092,8 +24518,9 @@ function createCodeBuddyInstallation(environment) {
|
|
|
24092
24518
|
}
|
|
24093
24519
|
|
|
24094
24520
|
// ../../harness-broker/dist/client.js
|
|
24521
|
+
import { execFile as execFile4 } from "node:child_process";
|
|
24095
24522
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
24096
|
-
import { lstat as
|
|
24523
|
+
import { lstat as lstat3, readFile as readFile5 } from "node:fs/promises";
|
|
24097
24524
|
import net, {} from "node:net";
|
|
24098
24525
|
|
|
24099
24526
|
// ../../harness-broker/dist/protocol.js
|
|
@@ -24102,9 +24529,12 @@ var HARNESS_BROKER_MAX_FRAME_BYTES = 8 * 1024 * 1024;
|
|
|
24102
24529
|
var HARNESS_BROKER_MAX_PENDING_REQUESTS = 32;
|
|
24103
24530
|
var HARNESS_BROKER_REQUEST_TIMEOUT_MS = 15e3;
|
|
24104
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";
|
|
24105
24534
|
var harnessBrokerMethodSchema = external_exports.enum([
|
|
24106
24535
|
"adapter.inspect",
|
|
24107
24536
|
"adapter.inspectAccount",
|
|
24537
|
+
"adapter.credits",
|
|
24108
24538
|
"adapter.open",
|
|
24109
24539
|
"adapter.sessionImport.list",
|
|
24110
24540
|
"adapter.sessionImport.resolve",
|
|
@@ -24211,18 +24641,26 @@ function consumeBrokerFrames(socket, onFrame, onError) {
|
|
|
24211
24641
|
|
|
24212
24642
|
// ../../harness-broker/dist/paths.js
|
|
24213
24643
|
import os2 from "node:os";
|
|
24214
|
-
import
|
|
24644
|
+
import path9 from "node:path";
|
|
24215
24645
|
var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
|
|
24216
24646
|
var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
|
|
24217
24647
|
function defaultHarnessBrokerDirectory(environment = process.env) {
|
|
24218
24648
|
const home = environment.HOME || os2.homedir();
|
|
24219
|
-
return
|
|
24649
|
+
return path9.join(home, ".codexhost", "harness-broker");
|
|
24220
24650
|
}
|
|
24221
24651
|
function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
|
|
24222
24652
|
harnessPluginIdSchema.parse(harnessId);
|
|
24223
24653
|
if (harnessId !== "claude-code")
|
|
24224
|
-
return
|
|
24225
|
-
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`);
|
|
24226
24664
|
}
|
|
24227
24665
|
|
|
24228
24666
|
// ../../harness-broker/dist/validation.js
|
|
@@ -24522,7 +24960,7 @@ function parseSessionMetadata(value) {
|
|
|
24522
24960
|
};
|
|
24523
24961
|
}
|
|
24524
24962
|
async function readDescriptor(descriptorPath) {
|
|
24525
|
-
const metadata = await
|
|
24963
|
+
const metadata = await lstat3(descriptorPath);
|
|
24526
24964
|
if (metadata.isSymbolicLink())
|
|
24527
24965
|
throw new Error("Aqua Harness broker descriptor must not be a symlink");
|
|
24528
24966
|
if (!metadata.isFile())
|
|
@@ -24534,12 +24972,12 @@ async function readDescriptor(descriptorPath) {
|
|
|
24534
24972
|
throw new Error("Aqua Harness broker descriptor belongs to another user");
|
|
24535
24973
|
}
|
|
24536
24974
|
}
|
|
24537
|
-
const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await
|
|
24975
|
+
const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await readFile5(descriptorPath, "utf8")));
|
|
24538
24976
|
if (process.platform === "darwin" && Buffer.byteLength(descriptor.socketPath) > 103) {
|
|
24539
24977
|
throw new Error("Aqua Harness broker socket path is too long for macOS");
|
|
24540
24978
|
}
|
|
24541
24979
|
if (process.platform !== "win32") {
|
|
24542
|
-
const socket = await
|
|
24980
|
+
const socket = await lstat3(descriptor.socketPath);
|
|
24543
24981
|
if (socket.isSymbolicLink() || !socket.isSocket()) {
|
|
24544
24982
|
throw new Error("Aqua Harness broker endpoint is not a Unix socket");
|
|
24545
24983
|
}
|
|
@@ -24550,10 +24988,55 @@ async function readDescriptor(descriptorPath) {
|
|
|
24550
24988
|
try {
|
|
24551
24989
|
process.kill(descriptor.ownerPid, 0);
|
|
24552
24990
|
} catch {
|
|
24553
|
-
throw new
|
|
24991
|
+
throw new BrokerNotRunningError("its owner process has exited");
|
|
24554
24992
|
}
|
|
24555
24993
|
return descriptor;
|
|
24556
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
|
+
}
|
|
24557
25040
|
var BrokerConnection = class _BrokerConnection {
|
|
24558
25041
|
#onClose;
|
|
24559
25042
|
onClose(callback) {
|
|
@@ -24577,21 +25060,31 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
24577
25060
|
socket.once("error", (error51) => this.#fail(error51));
|
|
24578
25061
|
}
|
|
24579
25062
|
static async connect(descriptorPath, harnessId) {
|
|
24580
|
-
|
|
24581
|
-
|
|
24582
|
-
|
|
24583
|
-
|
|
24584
|
-
|
|
24585
|
-
|
|
24586
|
-
|
|
24587
|
-
|
|
24588
|
-
|
|
24589
|
-
|
|
24590
|
-
|
|
24591
|
-
|
|
24592
|
-
|
|
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
|
+
});
|
|
24593
25082
|
});
|
|
24594
|
-
|
|
25083
|
+
socket = pending;
|
|
25084
|
+
} catch (error51) {
|
|
25085
|
+
connecting?.destroy();
|
|
25086
|
+
throw classifyConnectFailure(error51);
|
|
25087
|
+
}
|
|
24595
25088
|
const connection = new _BrokerConnection(descriptor, socket);
|
|
24596
25089
|
const hello = connection.#waitForHello();
|
|
24597
25090
|
await writeBrokerFrame(socket, {
|
|
@@ -24644,15 +25137,24 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
24644
25137
|
}, HARNESS_BROKER_REQUEST_TIMEOUT_MS);
|
|
24645
25138
|
this.#pending.set(id, { resolve, reject, timeout });
|
|
24646
25139
|
});
|
|
24647
|
-
|
|
24648
|
-
|
|
24649
|
-
|
|
24650
|
-
|
|
24651
|
-
|
|
24652
|
-
|
|
24653
|
-
|
|
24654
|
-
|
|
24655
|
-
|
|
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
|
+
}
|
|
24656
25158
|
return response;
|
|
24657
25159
|
}
|
|
24658
25160
|
close() {
|
|
@@ -24696,6 +25198,8 @@ var BrokerConnection = class _BrokerConnection {
|
|
|
24696
25198
|
this.#pending.delete(frame.id);
|
|
24697
25199
|
if (frame.ok)
|
|
24698
25200
|
pending.resolve(frame.value);
|
|
25201
|
+
else if (frame.error?.code === HARNESS_BROKER_RETIRING_ERROR_CODE)
|
|
25202
|
+
pending.reject(new BrokerRetiringError(frame.error.message));
|
|
24699
25203
|
else
|
|
24700
25204
|
pending.reject(new Error(frame.error?.message ?? "Broker request failed"));
|
|
24701
25205
|
}
|
|
@@ -24921,18 +25425,20 @@ var BrokeredHarnessAdapter = class {
|
|
|
24921
25425
|
harnessId;
|
|
24922
25426
|
#descriptorPath;
|
|
24923
25427
|
#forwardEnvironment;
|
|
25428
|
+
#isInstalled;
|
|
25429
|
+
#startBroker;
|
|
25430
|
+
#startTimeoutMs;
|
|
24924
25431
|
#connection = null;
|
|
24925
25432
|
#closed = false;
|
|
24926
25433
|
#sessionImportListing = null;
|
|
25434
|
+
#credits = null;
|
|
25435
|
+
#creditsRefresh = null;
|
|
24927
25436
|
subagents = {
|
|
24928
25437
|
readSnapshot: async (input) => {
|
|
24929
25438
|
try {
|
|
24930
|
-
return parseHarnessResult(await
|
|
25439
|
+
return parseHarnessResult(await this.#request("adapter.subagent.readSnapshot", input));
|
|
24931
25440
|
} catch (error51) {
|
|
24932
|
-
return {
|
|
24933
|
-
ok: false,
|
|
24934
|
-
error: unavailable(error51 instanceof Error ? error51.message : String(error51))
|
|
24935
|
-
};
|
|
25441
|
+
return { ok: false, error: this.#error(error51) };
|
|
24936
25442
|
}
|
|
24937
25443
|
}
|
|
24938
25444
|
};
|
|
@@ -25022,12 +25528,39 @@ var BrokeredHarnessAdapter = class {
|
|
|
25022
25528
|
if (input.liveCommandCatalog)
|
|
25023
25529
|
this.liveCommandCatalog = true;
|
|
25024
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;
|
|
25025
25558
|
}
|
|
25026
25559
|
async inspectAccount() {
|
|
25027
25560
|
if (this.#closed)
|
|
25028
25561
|
return null;
|
|
25029
25562
|
try {
|
|
25030
|
-
const value = await
|
|
25563
|
+
const value = await this.#request("adapter.inspectAccount", {}, true);
|
|
25031
25564
|
return harnessAccountSnapshotSchema.nullable().parse(value);
|
|
25032
25565
|
} catch {
|
|
25033
25566
|
return null;
|
|
@@ -25037,33 +25570,46 @@ var BrokeredHarnessAdapter = class {
|
|
|
25037
25570
|
if (this.#closed)
|
|
25038
25571
|
return failedInspection("Aqua Harness broker adapter is closed");
|
|
25039
25572
|
try {
|
|
25040
|
-
return harnessInspectionSchema.parse(await
|
|
25573
|
+
return harnessInspectionSchema.parse(await this.#request("adapter.inspect", input, true));
|
|
25041
25574
|
} catch (error51) {
|
|
25042
25575
|
this.#connection = null;
|
|
25043
|
-
|
|
25576
|
+
if (error51 instanceof HarnessNotInstalledError)
|
|
25577
|
+
return { status: "notInstalled", error: this.#error(error51) };
|
|
25578
|
+
return failedInspection(describeBrokerFailure(error51, this.harnessId));
|
|
25044
25579
|
}
|
|
25045
25580
|
}
|
|
25046
25581
|
async open(input) {
|
|
25047
25582
|
if (this.#closed)
|
|
25048
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
|
+
}
|
|
25049
25598
|
let connection;
|
|
25050
25599
|
try {
|
|
25051
|
-
|
|
25052
|
-
|
|
25053
|
-
|
|
25054
|
-
|
|
25055
|
-
"
|
|
25056
|
-
|
|
25057
|
-
|
|
25058
|
-
|
|
25059
|
-
|
|
25060
|
-
|
|
25061
|
-
|
|
25062
|
-
|
|
25063
|
-
|
|
25064
|
-
}
|
|
25065
|
-
connection = await this.#connect();
|
|
25066
|
-
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);
|
|
25067
25613
|
if (!result.ok)
|
|
25068
25614
|
return result;
|
|
25069
25615
|
const session = new BrokeredHarnessSession(connection, parseSessionMetadata(result.value), this.harnessId, safeInput, () => this.#connect(), () => {
|
|
@@ -25074,25 +25620,51 @@ var BrokeredHarnessAdapter = class {
|
|
|
25074
25620
|
} catch (error51) {
|
|
25075
25621
|
connection?.close();
|
|
25076
25622
|
this.#connection = null;
|
|
25077
|
-
return {
|
|
25078
|
-
ok: false,
|
|
25079
|
-
error: unavailable(error51 instanceof Error ? error51.message : String(error51))
|
|
25080
|
-
};
|
|
25623
|
+
return { ok: false, error: this.#error(error51) };
|
|
25081
25624
|
}
|
|
25082
25625
|
}
|
|
25083
25626
|
async close() {
|
|
25084
25627
|
this.#closed = true;
|
|
25628
|
+
this.#credits = null;
|
|
25085
25629
|
await Promise.allSettled([...this.#sessions].map((session) => session.close()));
|
|
25086
25630
|
this.#sessions.clear();
|
|
25087
25631
|
const connection = await this.#connection?.catch(() => null);
|
|
25088
25632
|
await connection?.dispose();
|
|
25089
25633
|
this.#connection = null;
|
|
25090
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
|
+
}
|
|
25091
25663
|
#connect() {
|
|
25092
25664
|
if (this.#closed)
|
|
25093
25665
|
return Promise.reject(new Error("Aqua Harness broker adapter is closed"));
|
|
25094
25666
|
if (!this.#connection) {
|
|
25095
|
-
const pending =
|
|
25667
|
+
const pending = this.#establish().then((connection) => {
|
|
25096
25668
|
connection.onClose(() => {
|
|
25097
25669
|
if (this.#connection === pending)
|
|
25098
25670
|
this.#connection = null;
|
|
@@ -25107,18 +25679,43 @@ var BrokeredHarnessAdapter = class {
|
|
|
25107
25679
|
}
|
|
25108
25680
|
return this.#connection;
|
|
25109
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
|
+
}
|
|
25110
25704
|
};
|
|
25111
25705
|
|
|
25112
25706
|
// dist/plugin.js
|
|
25113
25707
|
function createHarnessAdapter(context) {
|
|
25114
|
-
if (context.platform === "darwin" && context.managedRemoteHost)
|
|
25708
|
+
if (context.platform === "darwin" && context.managedRemoteHost) {
|
|
25709
|
+
const environment2 = { ...context.environment };
|
|
25115
25710
|
return new BrokeredHarnessAdapter({
|
|
25116
25711
|
harnessId: "codebuddy",
|
|
25117
25712
|
forwardDelegationEnvironment: true,
|
|
25118
25713
|
commandCatalog: CODEBUDDY_COMMAND_CATALOG,
|
|
25119
25714
|
liveCommandCatalog: true,
|
|
25120
|
-
environment:
|
|
25715
|
+
environment: environment2,
|
|
25716
|
+
isInstalled: () => resolveHarnessExecutable(codeBuddyDiscoverySpec, { environment: environment2 }) !== void 0
|
|
25121
25717
|
});
|
|
25718
|
+
}
|
|
25122
25719
|
const environment = { ...context.environment };
|
|
25123
25720
|
return Object.assign(new CodeBuddyAdapter({ environment }), {
|
|
25124
25721
|
installation: createCodeBuddyInstallation(environment),
|