@alan-ai-hq/agent-manager 0.1.111 → 0.1.112
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/dist/index.cjs +266 -254
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -15243,13 +15243,13 @@ Usage:
|
|
|
15243
15243
|
alan-agent <command> [options]
|
|
15244
15244
|
|
|
15245
15245
|
Commands:
|
|
15246
|
-
install Login/setup
|
|
15246
|
+
install Login/setup and install the daemon service (MCP + session sync are opt-in)
|
|
15247
15247
|
setup Register this computer with a setup token from Alan
|
|
15248
15248
|
login Register this computer through browser authorization
|
|
15249
15249
|
daemon Start the durable runtime daemon
|
|
15250
15250
|
service Install, uninstall, or inspect the per-user daemon service
|
|
15251
|
-
integrations Reconcile, inspect, or uninstall Alan
|
|
15252
|
-
hook Internal: durably spool a native CLI
|
|
15251
|
+
integrations Reconcile, inspect, or uninstall Alan MCP and session sync
|
|
15252
|
+
hook Internal: durably spool a native CLI session-sync event (fail-open)
|
|
15253
15253
|
stop Stop the local daemon (or active runs only via the local API /stop)
|
|
15254
15254
|
recover Redial and safely restart a stuck local daemon connection
|
|
15255
15255
|
status Show local runtime configuration without secrets
|
|
@@ -15263,6 +15263,7 @@ Commands:
|
|
|
15263
15263
|
Common flows:
|
|
15264
15264
|
alan-agent install
|
|
15265
15265
|
alan-agent install --setup-token <token>
|
|
15266
|
+
alan-agent install --with-integrations
|
|
15266
15267
|
alan-agent login
|
|
15267
15268
|
alan-agent login --cancel
|
|
15268
15269
|
alan-agent setup --setup-token <token>
|
|
@@ -15546,7 +15547,7 @@ function describeError(error61) {
|
|
|
15546
15547
|
}
|
|
15547
15548
|
|
|
15548
15549
|
// src/version.ts
|
|
15549
|
-
var AGENT_VERSION = "0.1.
|
|
15550
|
+
var AGENT_VERSION = "0.1.112";
|
|
15550
15551
|
|
|
15551
15552
|
// src/daemon-workspace.ts
|
|
15552
15553
|
var import_node_child_process3 = require("child_process");
|
|
@@ -15790,13 +15791,13 @@ function resolveRuntimeCwd(payload) {
|
|
|
15790
15791
|
|
|
15791
15792
|
// src/daemon-local-control.ts
|
|
15792
15793
|
var import_node_crypto5 = require("crypto");
|
|
15793
|
-
var
|
|
15794
|
-
var
|
|
15794
|
+
var import_node_fs9 = require("fs");
|
|
15795
|
+
var import_node_path10 = require("path");
|
|
15795
15796
|
|
|
15796
15797
|
// src/daemon-runner-status.ts
|
|
15797
|
-
var
|
|
15798
|
+
var import_node_fs8 = require("fs");
|
|
15798
15799
|
var import_node_os5 = require("os");
|
|
15799
|
-
var
|
|
15800
|
+
var import_node_path9 = require("path");
|
|
15800
15801
|
|
|
15801
15802
|
// ../shared/dist/node/provider-limits.js
|
|
15802
15803
|
var import_node_child_process4 = require("child_process");
|
|
@@ -47990,80 +47991,9 @@ ${result.stderr}`.trim();
|
|
|
47990
47991
|
}
|
|
47991
47992
|
|
|
47992
47993
|
// src/workspace-run-lease.ts
|
|
47993
|
-
var import_node_child_process6 = require("child_process");
|
|
47994
|
-
var import_promises5 = require("fs/promises");
|
|
47995
|
-
var import_node_path9 = require("path");
|
|
47996
|
-
|
|
47997
|
-
// src/workspace-relocation.ts
|
|
47998
47994
|
var import_node_child_process5 = require("child_process");
|
|
47999
|
-
var
|
|
47995
|
+
var import_promises5 = require("fs/promises");
|
|
48000
47996
|
var import_node_path8 = require("path");
|
|
48001
|
-
var MAX_RELOCATION_CANDIDATES = 200;
|
|
48002
|
-
var DEFAULT_PROBE = {
|
|
48003
|
-
childDirectories: (parentPath, limit) => (0, import_node_fs8.readdirSync)(parentPath, { withFileTypes: true }).filter((entry) => entry.isDirectory()).slice(0, limit).map((entry) => (0, import_node_path8.join)(parentPath, entry.name)),
|
|
48004
|
-
gitRemoteUrl: (candidatePath) => {
|
|
48005
|
-
const result = (0, import_node_child_process5.spawnSync)("git", ["-C", candidatePath, "config", "--get", "remote.origin.url"], {
|
|
48006
|
-
encoding: "utf8",
|
|
48007
|
-
env: getDaemonCliEnvironment(),
|
|
48008
|
-
timeout: 2e3
|
|
48009
|
-
});
|
|
48010
|
-
if (result.status !== 0) return null;
|
|
48011
|
-
const url3 = result.stdout.trim();
|
|
48012
|
-
return url3 || null;
|
|
48013
|
-
}
|
|
48014
|
-
};
|
|
48015
|
-
function normalizeRepositoryIdentity(value2) {
|
|
48016
|
-
const trimmed = value2.trim().replace(/\/+$/, "").replace(/\.git$/i, "");
|
|
48017
|
-
if (!trimmed) return null;
|
|
48018
|
-
const scp = trimmed.match(/^(?:[^@/]+@)?([^:/]+):(.+)$/);
|
|
48019
|
-
if (scp && !trimmed.includes("://")) {
|
|
48020
|
-
return `${scp[1]}/${scp[2]}`.toLowerCase();
|
|
48021
|
-
}
|
|
48022
|
-
try {
|
|
48023
|
-
const url3 = new URL(trimmed);
|
|
48024
|
-
return `${url3.hostname}${url3.pathname}`.replace(/\/+$/, "").toLowerCase();
|
|
48025
|
-
} catch {
|
|
48026
|
-
return null;
|
|
48027
|
-
}
|
|
48028
|
-
}
|
|
48029
|
-
function workspaceMatchesExpectedRepositories(input2) {
|
|
48030
|
-
const identities = new Set(
|
|
48031
|
-
input2.expectedRepoUrls.map(normalizeRepositoryIdentity).filter((identity3) => Boolean(identity3))
|
|
48032
|
-
);
|
|
48033
|
-
if (identities.size === 0) return false;
|
|
48034
|
-
const remote = (input2.probe ?? DEFAULT_PROBE).gitRemoteUrl((0, import_node_path8.resolve)(input2.workspacePath));
|
|
48035
|
-
const identity2 = remote ? normalizeRepositoryIdentity(remote) : null;
|
|
48036
|
-
return Boolean(identity2 && identities.has(identity2));
|
|
48037
|
-
}
|
|
48038
|
-
function discoverRelocatedWorkspace(input2) {
|
|
48039
|
-
const identities = new Set(
|
|
48040
|
-
input2.expectedRepoUrls.map(normalizeRepositoryIdentity).filter((identity2) => Boolean(identity2))
|
|
48041
|
-
);
|
|
48042
|
-
if (identities.size === 0) return null;
|
|
48043
|
-
const searchRoots = [
|
|
48044
|
-
(0, import_node_path8.dirname)((0, import_node_path8.resolve)(input2.missingPath)),
|
|
48045
|
-
...(input2.approvedWorkspacePaths ?? []).map((path2) => (0, import_node_path8.dirname)((0, import_node_path8.resolve)(path2)))
|
|
48046
|
-
].filter((path2, index, paths) => paths.indexOf(path2) === index);
|
|
48047
|
-
const candidates = [];
|
|
48048
|
-
for (const root of searchRoots) {
|
|
48049
|
-
const remaining = MAX_RELOCATION_CANDIDATES - candidates.length;
|
|
48050
|
-
if (remaining <= 0) break;
|
|
48051
|
-
try {
|
|
48052
|
-
candidates.push(...(input2.probe ?? DEFAULT_PROBE).childDirectories(root, remaining));
|
|
48053
|
-
} catch {
|
|
48054
|
-
}
|
|
48055
|
-
}
|
|
48056
|
-
const matches = [];
|
|
48057
|
-
for (const candidate of new Set(candidates.map((path2) => (0, import_node_path8.resolve)(path2)))) {
|
|
48058
|
-
const remote = (input2.probe ?? DEFAULT_PROBE).gitRemoteUrl(candidate);
|
|
48059
|
-
const identity2 = remote ? normalizeRepositoryIdentity(remote) : null;
|
|
48060
|
-
if (identity2 && identities.has(identity2)) matches.push((0, import_node_path8.resolve)(candidate));
|
|
48061
|
-
if (matches.length > 1) return null;
|
|
48062
|
-
}
|
|
48063
|
-
return matches[0] ?? null;
|
|
48064
|
-
}
|
|
48065
|
-
|
|
48066
|
-
// src/workspace-run-lease.ts
|
|
48067
47997
|
var WORKSPACE_LEASE_CHECK_INTERVAL_MS = 1e3;
|
|
48068
47998
|
function parsePositiveMs(value2, fallback) {
|
|
48069
47999
|
const parsed = value2 ? Number(value2) : Number.NaN;
|
|
@@ -48079,19 +48009,19 @@ function applicationCodeForWorkspaceLeaseFailure(code) {
|
|
|
48079
48009
|
async function hasGitWorkspaceMarker(workspacePath) {
|
|
48080
48010
|
let directory;
|
|
48081
48011
|
try {
|
|
48082
|
-
directory = await (0, import_promises5.realpath)((0,
|
|
48012
|
+
directory = await (0, import_promises5.realpath)((0, import_node_path8.resolve)(workspacePath));
|
|
48083
48013
|
} catch {
|
|
48084
48014
|
return true;
|
|
48085
48015
|
}
|
|
48086
48016
|
while (true) {
|
|
48087
48017
|
try {
|
|
48088
|
-
await (0, import_promises5.stat)((0,
|
|
48018
|
+
await (0, import_promises5.stat)((0, import_node_path8.join)(directory, ".git"));
|
|
48089
48019
|
return true;
|
|
48090
48020
|
} catch (error61) {
|
|
48091
48021
|
const code = error61.code;
|
|
48092
48022
|
if (code !== "ENOENT" && code !== "ENOTDIR") return true;
|
|
48093
48023
|
}
|
|
48094
|
-
const parent = (0,
|
|
48024
|
+
const parent = (0, import_node_path8.dirname)(directory);
|
|
48095
48025
|
if (parent === directory) return false;
|
|
48096
48026
|
directory = parent;
|
|
48097
48027
|
}
|
|
@@ -48103,7 +48033,7 @@ async function gitValue(cwd, args) {
|
|
|
48103
48033
|
else runningGitProbes++;
|
|
48104
48034
|
try {
|
|
48105
48035
|
return await new Promise((resolve16) => {
|
|
48106
|
-
(0,
|
|
48036
|
+
(0, import_node_child_process5.execFile)(
|
|
48107
48037
|
"git",
|
|
48108
48038
|
["-C", cwd, ...args],
|
|
48109
48039
|
{
|
|
@@ -48129,7 +48059,7 @@ async function filesystemIdentity(path2) {
|
|
|
48129
48059
|
return `${canonicalPath}:${metadata.dev}:${metadata.ino}`;
|
|
48130
48060
|
}
|
|
48131
48061
|
function resolveGitPath(workspacePath, value2) {
|
|
48132
|
-
return (0,
|
|
48062
|
+
return (0, import_node_path8.isAbsolute)(value2) ? value2 : (0, import_node_path8.resolve)(workspacePath, value2);
|
|
48133
48063
|
}
|
|
48134
48064
|
function createWorkspaceRunLeaseSnapshotProbe(loadSnapshot) {
|
|
48135
48065
|
const snapshots = /* @__PURE__ */ new Map();
|
|
@@ -48151,7 +48081,7 @@ function createWorkspaceRunLeaseSnapshotProbe(loadSnapshot) {
|
|
|
48151
48081
|
return pending.promise;
|
|
48152
48082
|
};
|
|
48153
48083
|
return (workspacePath, options) => {
|
|
48154
|
-
const key = process.platform === "win32" ? (0,
|
|
48084
|
+
const key = process.platform === "win32" ? (0, import_node_path8.resolve)(workspacePath).toLowerCase() : (0, import_node_path8.resolve)(workspacePath);
|
|
48155
48085
|
const existing = snapshots.get(key);
|
|
48156
48086
|
if (!existing) return startSnapshot(key, options?.coalescePending === true);
|
|
48157
48087
|
if (!options?.fresh) return existing.promise;
|
|
@@ -48164,11 +48094,11 @@ function createWorkspaceRunLeaseSnapshotProbe(loadSnapshot) {
|
|
|
48164
48094
|
return existing.freshAfterPending;
|
|
48165
48095
|
};
|
|
48166
48096
|
}
|
|
48167
|
-
var
|
|
48097
|
+
var DEFAULT_PROBE = {
|
|
48168
48098
|
snapshot: createWorkspaceRunLeaseSnapshotProbe(snapshotWorkspace),
|
|
48169
48099
|
pathExists: async (workspacePath) => {
|
|
48170
48100
|
try {
|
|
48171
|
-
await (0, import_promises5.access)((0,
|
|
48101
|
+
await (0, import_promises5.access)((0, import_node_path8.resolve)(workspacePath));
|
|
48172
48102
|
return true;
|
|
48173
48103
|
} catch (error61) {
|
|
48174
48104
|
return error61.code !== "ENOENT";
|
|
@@ -48177,7 +48107,7 @@ var DEFAULT_PROBE2 = {
|
|
|
48177
48107
|
};
|
|
48178
48108
|
async function snapshotWorkspace(workspacePath) {
|
|
48179
48109
|
try {
|
|
48180
|
-
const canonicalWorkspacePath = await (0, import_promises5.realpath)((0,
|
|
48110
|
+
const canonicalWorkspacePath = await (0, import_promises5.realpath)((0, import_node_path8.resolve)(workspacePath));
|
|
48181
48111
|
const repositoryRoot = await gitValue(canonicalWorkspacePath, ["rev-parse", "--show-toplevel"]);
|
|
48182
48112
|
const gitDirectory = await gitValue(canonicalWorkspacePath, ["rev-parse", "--git-dir"]);
|
|
48183
48113
|
const commonDirectory = await gitValue(canonicalWorkspacePath, [
|
|
@@ -48186,14 +48116,15 @@ async function snapshotWorkspace(workspacePath) {
|
|
|
48186
48116
|
]);
|
|
48187
48117
|
const branch = await gitValue(canonicalWorkspacePath, ["branch", "--show-current"]) ?? "";
|
|
48188
48118
|
if (!repositoryRoot || !gitDirectory || !commonDirectory) return null;
|
|
48189
|
-
const remote = await gitValue(canonicalWorkspacePath, ["config", "--get", "remote.origin.url"]);
|
|
48190
|
-
const remoteIdentity = remote ? normalizeRepositoryIdentity(remote) : null;
|
|
48191
48119
|
return {
|
|
48192
|
-
workspacePath: (0,
|
|
48120
|
+
workspacePath: (0, import_node_path8.resolve)(workspacePath),
|
|
48193
48121
|
workspaceIdentity: await filesystemIdentity(canonicalWorkspacePath),
|
|
48194
|
-
|
|
48122
|
+
// The common Git directory identifies the checkout. A coding agent may
|
|
48123
|
+
// legitimately add or update origin without replacing that directory;
|
|
48124
|
+
// treating remote configuration as filesystem identity stops its run.
|
|
48125
|
+
repositoryIdentity: await filesystemIdentity(
|
|
48195
48126
|
resolveGitPath(canonicalWorkspacePath, commonDirectory)
|
|
48196
|
-
)
|
|
48127
|
+
),
|
|
48197
48128
|
worktreeIdentity: await filesystemIdentity(
|
|
48198
48129
|
resolveGitPath(canonicalWorkspacePath, gitDirectory)
|
|
48199
48130
|
),
|
|
@@ -48229,10 +48160,10 @@ var WorkspaceRunLease = class _WorkspaceRunLease {
|
|
|
48229
48160
|
this.captured = captured;
|
|
48230
48161
|
this.probe = probe;
|
|
48231
48162
|
}
|
|
48232
|
-
static async capture(targets, probe =
|
|
48163
|
+
static async capture(targets, probe = DEFAULT_PROBE) {
|
|
48233
48164
|
const captured = [];
|
|
48234
48165
|
for (const target of targets) {
|
|
48235
|
-
const normalizedTarget = { ...target, workspacePath: (0,
|
|
48166
|
+
const normalizedTarget = { ...target, workspacePath: (0, import_node_path8.resolve)(target.workspacePath) };
|
|
48236
48167
|
const identity2 = await probe.snapshot(normalizedTarget.workspacePath, {
|
|
48237
48168
|
fresh: true,
|
|
48238
48169
|
coalescePending: true
|
|
@@ -48775,13 +48706,13 @@ var DurablePendingRunStarts = class extends Map {
|
|
|
48775
48706
|
}
|
|
48776
48707
|
persist() {
|
|
48777
48708
|
if (this.size === 0) {
|
|
48778
|
-
(0,
|
|
48709
|
+
(0, import_node_fs8.rmSync)(this.path, { force: true });
|
|
48779
48710
|
return;
|
|
48780
48711
|
}
|
|
48781
48712
|
const pendingPath = `${this.path}.pending`;
|
|
48782
|
-
(0,
|
|
48713
|
+
(0, import_node_fs8.mkdirSync)((0, import_node_path9.dirname)(this.path), { recursive: true, mode: 448 });
|
|
48783
48714
|
try {
|
|
48784
|
-
(0,
|
|
48715
|
+
(0, import_node_fs8.writeFileSync)(
|
|
48785
48716
|
pendingPath,
|
|
48786
48717
|
JSON.stringify({
|
|
48787
48718
|
version: 1,
|
|
@@ -48794,10 +48725,10 @@ var DurablePendingRunStarts = class extends Map {
|
|
|
48794
48725
|
}),
|
|
48795
48726
|
{ mode: 384 }
|
|
48796
48727
|
);
|
|
48797
|
-
(0,
|
|
48798
|
-
(0,
|
|
48728
|
+
(0, import_node_fs8.chmodSync)(pendingPath, 384);
|
|
48729
|
+
(0, import_node_fs8.renameSync)(pendingPath, this.path);
|
|
48799
48730
|
} finally {
|
|
48800
|
-
(0,
|
|
48731
|
+
(0, import_node_fs8.rmSync)(pendingPath, { force: true });
|
|
48801
48732
|
}
|
|
48802
48733
|
}
|
|
48803
48734
|
};
|
|
@@ -49041,7 +48972,7 @@ function collectRuntimeMetadata() {
|
|
|
49041
48972
|
metadata.cpuCores = cpuList.length;
|
|
49042
48973
|
}
|
|
49043
48974
|
try {
|
|
49044
|
-
const disk = (0,
|
|
48975
|
+
const disk = (0, import_node_fs8.statfsSync)((0, import_node_os5.homedir)());
|
|
49045
48976
|
metadata.diskFreeBytes = disk.bavail * disk.bsize;
|
|
49046
48977
|
metadata.diskTotalBytes = disk.blocks * disk.bsize;
|
|
49047
48978
|
} catch {
|
|
@@ -49248,12 +49179,12 @@ function getConfigPath() {
|
|
|
49248
49179
|
return boundAgentConfigPath ?? process.env.ALAN_AGENT_CONFIG_PATH ?? resolveAgentConfigPath({ profile: "production" });
|
|
49249
49180
|
}
|
|
49250
49181
|
function getEndpointDefaultsPath() {
|
|
49251
|
-
return process.env.ALAN_AGENT_ENDPOINTS_PATH ?? (0,
|
|
49182
|
+
return process.env.ALAN_AGENT_ENDPOINTS_PATH ?? (0, import_node_path10.join)((0, import_node_path10.dirname)(getConfigPath()), "endpoints.json");
|
|
49252
49183
|
}
|
|
49253
49184
|
function readConfig() {
|
|
49254
49185
|
const configPath = getConfigPath();
|
|
49255
|
-
if (!(0,
|
|
49256
|
-
const parsed = JSON.parse((0,
|
|
49186
|
+
if (!(0, import_node_fs9.existsSync)(configPath)) return {};
|
|
49187
|
+
const parsed = JSON.parse((0, import_node_fs9.readFileSync)(configPath, "utf8"));
|
|
49257
49188
|
const sanitized = sanitizeAgentConfig(parsed);
|
|
49258
49189
|
if (Object.keys(parsed).some((key) => !Object.hasOwn(sanitized, key))) {
|
|
49259
49190
|
writeConfig(sanitized);
|
|
@@ -49269,27 +49200,27 @@ function readConfigForRegistration() {
|
|
|
49269
49200
|
}
|
|
49270
49201
|
function readEndpointDefaults() {
|
|
49271
49202
|
const endpointsPath = getEndpointDefaultsPath();
|
|
49272
|
-
if (!(0,
|
|
49203
|
+
if (!(0, import_node_fs9.existsSync)(endpointsPath)) return {};
|
|
49273
49204
|
try {
|
|
49274
|
-
return JSON.parse((0,
|
|
49205
|
+
return JSON.parse((0, import_node_fs9.readFileSync)(endpointsPath, "utf8"));
|
|
49275
49206
|
} catch {
|
|
49276
49207
|
return {};
|
|
49277
49208
|
}
|
|
49278
49209
|
}
|
|
49279
49210
|
function writeConfig(config2) {
|
|
49280
49211
|
const configPath = getConfigPath();
|
|
49281
|
-
(0,
|
|
49212
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(configPath), { recursive: true, mode: 448 });
|
|
49282
49213
|
const pendingPath = `${configPath}.pending-${process.pid}-${(0, import_node_crypto5.randomBytes)(6).toString("hex")}`;
|
|
49283
49214
|
try {
|
|
49284
|
-
(0,
|
|
49215
|
+
(0, import_node_fs9.writeFileSync)(
|
|
49285
49216
|
pendingPath,
|
|
49286
49217
|
JSON.stringify(sanitizeAgentConfig(config2), null, 2),
|
|
49287
49218
|
{ mode: 384 }
|
|
49288
49219
|
);
|
|
49289
|
-
(0,
|
|
49290
|
-
(0,
|
|
49220
|
+
(0, import_node_fs9.chmodSync)(pendingPath, 384);
|
|
49221
|
+
(0, import_node_fs9.renameSync)(pendingPath, configPath);
|
|
49291
49222
|
} finally {
|
|
49292
|
-
(0,
|
|
49223
|
+
(0, import_node_fs9.rmSync)(pendingPath, { force: true });
|
|
49293
49224
|
}
|
|
49294
49225
|
}
|
|
49295
49226
|
function maintenanceLeasePath(configPath) {
|
|
@@ -49297,9 +49228,9 @@ function maintenanceLeasePath(configPath) {
|
|
|
49297
49228
|
}
|
|
49298
49229
|
function readLocalDaemonMaintenanceLease(configPath, nowMs = Date.now()) {
|
|
49299
49230
|
const path2 = maintenanceLeasePath(configPath);
|
|
49300
|
-
if (!(0,
|
|
49231
|
+
if (!(0, import_node_fs9.existsSync)(path2)) return null;
|
|
49301
49232
|
try {
|
|
49302
|
-
const lease = JSON.parse((0,
|
|
49233
|
+
const lease = JSON.parse((0, import_node_fs9.readFileSync)(path2, "utf8"));
|
|
49303
49234
|
if (lease.version !== 1 || typeof lease.id !== "string" || lease.reason !== "credential_cleanup" && lease.reason !== "credential_swap" && lease.reason !== "daemon_startup" && lease.reason !== "watchdog" || !(lease.reason === "credential_cleanup" && lease.expiresAtMs === null || typeof lease.expiresAtMs === "number" && Number.isFinite(lease.expiresAtMs))) {
|
|
49304
49235
|
throw new Error("invalid maintenance lease");
|
|
49305
49236
|
}
|
|
@@ -49316,8 +49247,8 @@ function readLocalDaemonMaintenanceLease(configPath, nowMs = Date.now()) {
|
|
|
49316
49247
|
expiresAtMs: nowMs + 5e3
|
|
49317
49248
|
};
|
|
49318
49249
|
try {
|
|
49319
|
-
(0,
|
|
49320
|
-
(0,
|
|
49250
|
+
(0, import_node_fs9.writeFileSync)(path2, JSON.stringify(fallback), { mode: 384 });
|
|
49251
|
+
(0, import_node_fs9.chmodSync)(path2, 384);
|
|
49321
49252
|
} catch {
|
|
49322
49253
|
}
|
|
49323
49254
|
return fallback;
|
|
@@ -49333,10 +49264,10 @@ function acquireLocalDaemonMaintenanceLease(configPath, reason, ttlMs = 5e3) {
|
|
|
49333
49264
|
expiresAtMs: reason === "credential_cleanup" ? null : Date.now() + Math.max(1e3, Math.min(ttlMs, 6e4))
|
|
49334
49265
|
};
|
|
49335
49266
|
const path2 = maintenanceLeasePath(configPath);
|
|
49336
|
-
(0,
|
|
49267
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(path2), { recursive: true, mode: 448 });
|
|
49337
49268
|
try {
|
|
49338
|
-
(0,
|
|
49339
|
-
(0,
|
|
49269
|
+
(0, import_node_fs9.writeFileSync)(path2, JSON.stringify(lease), { mode: 384, flag: "wx" });
|
|
49270
|
+
(0, import_node_fs9.chmodSync)(path2, 384);
|
|
49340
49271
|
return { acquired: true, lease };
|
|
49341
49272
|
} catch (error61) {
|
|
49342
49273
|
const raced = readLocalDaemonMaintenanceLease(configPath);
|
|
@@ -49352,9 +49283,9 @@ function daemonOwnerLeasePath(configPath) {
|
|
|
49352
49283
|
}
|
|
49353
49284
|
function readLocalDaemonOwnerLease(configPath) {
|
|
49354
49285
|
const path2 = daemonOwnerLeasePath(configPath);
|
|
49355
|
-
if (!(0,
|
|
49286
|
+
if (!(0, import_node_fs9.existsSync)(path2)) return null;
|
|
49356
49287
|
try {
|
|
49357
|
-
const lease = JSON.parse((0,
|
|
49288
|
+
const lease = JSON.parse((0, import_node_fs9.readFileSync)(path2, "utf8"));
|
|
49358
49289
|
if (lease.version !== 1 || typeof lease.id !== "string" || typeof lease.daemonSessionId !== "string" || !Number.isSafeInteger(lease.pid) || lease.pid <= 0 || typeof lease.startedAtMs !== "number" || !Number.isFinite(lease.startedAtMs) || typeof lease.runtimeId !== "string" || typeof lease.localServiceId !== "string" || !Number.isSafeInteger(lease.localApiPort) || lease.localApiPort < 0 || lease.localApiPort > 65535 || typeof lease.localApiToken !== "string" || lease.localApiToken.length === 0) {
|
|
49359
49290
|
throw new Error("invalid daemon owner lease");
|
|
49360
49291
|
}
|
|
@@ -49409,10 +49340,10 @@ async function acquireLocalDaemonOwnerLease(input2) {
|
|
|
49409
49340
|
localApiToken: input2.localApiToken
|
|
49410
49341
|
};
|
|
49411
49342
|
const path2 = daemonOwnerLeasePath(input2.configPath);
|
|
49412
|
-
(0,
|
|
49343
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(path2), { recursive: true, mode: 448 });
|
|
49413
49344
|
try {
|
|
49414
|
-
(0,
|
|
49415
|
-
(0,
|
|
49345
|
+
(0, import_node_fs9.writeFileSync)(path2, JSON.stringify(lease), { mode: 384, flag: "wx" });
|
|
49346
|
+
(0, import_node_fs9.chmodSync)(path2, 384);
|
|
49416
49347
|
return { acquired: true, lease };
|
|
49417
49348
|
} catch (error61) {
|
|
49418
49349
|
const raced = readLocalDaemonOwnerLease(input2.configPath);
|
|
@@ -49427,12 +49358,12 @@ function updateLocalDaemonOwnerEndpoint(configPath, lease, localApiPort) {
|
|
|
49427
49358
|
const path2 = daemonOwnerLeasePath(configPath);
|
|
49428
49359
|
const pendingPath = `${path2}.pending-${lease.id}`;
|
|
49429
49360
|
try {
|
|
49430
|
-
(0,
|
|
49431
|
-
(0,
|
|
49432
|
-
(0,
|
|
49361
|
+
(0, import_node_fs9.writeFileSync)(pendingPath, JSON.stringify(updated), { mode: 384 });
|
|
49362
|
+
(0, import_node_fs9.chmodSync)(pendingPath, 384);
|
|
49363
|
+
(0, import_node_fs9.renameSync)(pendingPath, path2);
|
|
49433
49364
|
return updated;
|
|
49434
49365
|
} finally {
|
|
49435
|
-
(0,
|
|
49366
|
+
(0, import_node_fs9.rmSync)(pendingPath, { force: true });
|
|
49436
49367
|
}
|
|
49437
49368
|
}
|
|
49438
49369
|
function releaseLocalDaemonOwnerLease(configPath, leaseId) {
|
|
@@ -49441,13 +49372,13 @@ function releaseLocalDaemonOwnerLease(configPath, leaseId) {
|
|
|
49441
49372
|
function releaseOwnedJsonFile(path2, ownerId, ownerField = "id") {
|
|
49442
49373
|
const releasePath = `${path2}.release-${process.pid}-${(0, import_node_crypto5.randomBytes)(6).toString("hex")}`;
|
|
49443
49374
|
try {
|
|
49444
|
-
(0,
|
|
49375
|
+
(0, import_node_fs9.renameSync)(path2, releasePath);
|
|
49445
49376
|
} catch (error61) {
|
|
49446
49377
|
if (error61.code === "ENOENT") return;
|
|
49447
49378
|
throw error61;
|
|
49448
49379
|
}
|
|
49449
49380
|
try {
|
|
49450
|
-
const content = (0,
|
|
49381
|
+
const content = (0, import_node_fs9.readFileSync)(releasePath, "utf8");
|
|
49451
49382
|
let capturedOwnerId = null;
|
|
49452
49383
|
try {
|
|
49453
49384
|
const captured = JSON.parse(content);
|
|
@@ -49456,13 +49387,13 @@ function releaseOwnedJsonFile(path2, ownerId, ownerField = "id") {
|
|
|
49456
49387
|
}
|
|
49457
49388
|
if (capturedOwnerId === ownerId) return;
|
|
49458
49389
|
try {
|
|
49459
|
-
(0,
|
|
49460
|
-
(0,
|
|
49390
|
+
(0, import_node_fs9.writeFileSync)(path2, content, { mode: 384, flag: "wx" });
|
|
49391
|
+
(0, import_node_fs9.chmodSync)(path2, 384);
|
|
49461
49392
|
} catch (error61) {
|
|
49462
49393
|
if (error61.code !== "EEXIST") throw error61;
|
|
49463
49394
|
}
|
|
49464
49395
|
} finally {
|
|
49465
|
-
(0,
|
|
49396
|
+
(0, import_node_fs9.rmSync)(releasePath, { force: true });
|
|
49466
49397
|
}
|
|
49467
49398
|
}
|
|
49468
49399
|
function inspectLocalDaemonRunJournal(configPath) {
|
|
@@ -49472,8 +49403,8 @@ function inspectLocalDaemonRunJournal(configPath) {
|
|
|
49472
49403
|
try {
|
|
49473
49404
|
let activeRunCount = 0;
|
|
49474
49405
|
for (const artifact of [path2, pendingPath]) {
|
|
49475
|
-
if (!(0,
|
|
49476
|
-
const parsed = JSON.parse((0,
|
|
49406
|
+
if (!(0, import_node_fs9.existsSync)(artifact)) continue;
|
|
49407
|
+
const parsed = JSON.parse((0, import_node_fs9.readFileSync)(artifact, "utf8"));
|
|
49477
49408
|
if (parsed.version !== 1 || !Array.isArray(parsed.entries))
|
|
49478
49409
|
throw new Error("invalid journal");
|
|
49479
49410
|
if (artifact === path2) {
|
|
@@ -49492,7 +49423,7 @@ function inspectLocalDaemonRunJournal(configPath) {
|
|
|
49492
49423
|
}).length;
|
|
49493
49424
|
continue;
|
|
49494
49425
|
}
|
|
49495
|
-
const legacyStartedAtMs = (0,
|
|
49426
|
+
const legacyStartedAtMs = (0, import_node_fs9.statSync)(pendingPath).mtimeMs;
|
|
49496
49427
|
activeRunCount += parsed.entries.filter((entry) => {
|
|
49497
49428
|
if (!entry || typeof entry !== "object") throw new Error("invalid pending run entry");
|
|
49498
49429
|
const startedAtMs = entry.startedAtMs;
|
|
@@ -49519,9 +49450,9 @@ function setupTokenHash(setupToken) {
|
|
|
49519
49450
|
function getOrCreateSetupAttemptId(setupToken) {
|
|
49520
49451
|
const intentPath = pendingSetupIntentPath();
|
|
49521
49452
|
const tokenHash = setupTokenHash(setupToken);
|
|
49522
|
-
if ((0,
|
|
49453
|
+
if ((0, import_node_fs9.existsSync)(intentPath)) {
|
|
49523
49454
|
try {
|
|
49524
|
-
const stored = JSON.parse((0,
|
|
49455
|
+
const stored = JSON.parse((0, import_node_fs9.readFileSync)(intentPath, "utf8"));
|
|
49525
49456
|
if (stored.setupTokenHash === tokenHash && typeof stored.registrationAttemptId === "string" && stored.registrationAttemptId.length > 0) {
|
|
49526
49457
|
return stored.registrationAttemptId;
|
|
49527
49458
|
}
|
|
@@ -49529,23 +49460,23 @@ function getOrCreateSetupAttemptId(setupToken) {
|
|
|
49529
49460
|
}
|
|
49530
49461
|
}
|
|
49531
49462
|
const registrationAttemptId = (0, import_node_crypto5.randomUUID)();
|
|
49532
|
-
(0,
|
|
49463
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(intentPath), { recursive: true, mode: 448 });
|
|
49533
49464
|
const writePath = `${intentPath}.pending-${process.pid}-${(0, import_node_crypto5.randomBytes)(6).toString("hex")}`;
|
|
49534
49465
|
try {
|
|
49535
|
-
(0,
|
|
49466
|
+
(0, import_node_fs9.writeFileSync)(
|
|
49536
49467
|
writePath,
|
|
49537
49468
|
JSON.stringify({ setupTokenHash: tokenHash, registrationAttemptId }, null, 2),
|
|
49538
49469
|
{ mode: 384 }
|
|
49539
49470
|
);
|
|
49540
|
-
(0,
|
|
49541
|
-
(0,
|
|
49471
|
+
(0, import_node_fs9.chmodSync)(writePath, 384);
|
|
49472
|
+
(0, import_node_fs9.renameSync)(writePath, intentPath);
|
|
49542
49473
|
} finally {
|
|
49543
|
-
(0,
|
|
49474
|
+
(0, import_node_fs9.rmSync)(writePath, { force: true });
|
|
49544
49475
|
}
|
|
49545
49476
|
return registrationAttemptId;
|
|
49546
49477
|
}
|
|
49547
49478
|
function clearPendingSetupIntent() {
|
|
49548
|
-
(0,
|
|
49479
|
+
(0, import_node_fs9.rmSync)(pendingSetupIntentPath(), { force: true });
|
|
49549
49480
|
}
|
|
49550
49481
|
function pendingDeviceAuthorizationPath() {
|
|
49551
49482
|
return `${getConfigPath()}.device-auth-pending`;
|
|
@@ -49566,8 +49497,8 @@ function parseDeviceAuthorizationOperationContent(content) {
|
|
|
49566
49497
|
}
|
|
49567
49498
|
function restoreCapturedFileUnlessReplaced(path2, content) {
|
|
49568
49499
|
try {
|
|
49569
|
-
(0,
|
|
49570
|
-
(0,
|
|
49500
|
+
(0, import_node_fs9.writeFileSync)(path2, content, { mode: 384, flag: "wx" });
|
|
49501
|
+
(0, import_node_fs9.chmodSync)(path2, 384);
|
|
49571
49502
|
} catch (error61) {
|
|
49572
49503
|
if (error61.code !== "EEXIST") throw error61;
|
|
49573
49504
|
}
|
|
@@ -49575,26 +49506,26 @@ function restoreCapturedFileUnlessReplaced(path2, content) {
|
|
|
49575
49506
|
function quarantineCorruptDeviceAuthorizationOperation(path2) {
|
|
49576
49507
|
const quarantinePath = `${path2}.corrupt-${process.pid}-${(0, import_node_crypto5.randomBytes)(6).toString("hex")}`;
|
|
49577
49508
|
try {
|
|
49578
|
-
(0,
|
|
49509
|
+
(0, import_node_fs9.renameSync)(path2, quarantinePath);
|
|
49579
49510
|
} catch (error61) {
|
|
49580
49511
|
if (error61.code === "ENOENT") return null;
|
|
49581
49512
|
throw error61;
|
|
49582
49513
|
}
|
|
49583
49514
|
try {
|
|
49584
|
-
const capturedContent = (0,
|
|
49515
|
+
const capturedContent = (0, import_node_fs9.readFileSync)(quarantinePath, "utf8");
|
|
49585
49516
|
if (parseDeviceAuthorizationOperationContent(capturedContent)) {
|
|
49586
49517
|
restoreCapturedFileUnlessReplaced(path2, capturedContent);
|
|
49587
49518
|
}
|
|
49588
49519
|
} finally {
|
|
49589
|
-
(0,
|
|
49520
|
+
(0, import_node_fs9.rmSync)(quarantinePath, { force: true });
|
|
49590
49521
|
}
|
|
49591
|
-
if (!(0,
|
|
49592
|
-
return parseDeviceAuthorizationOperationContent((0,
|
|
49522
|
+
if (!(0, import_node_fs9.existsSync)(path2)) return null;
|
|
49523
|
+
return parseDeviceAuthorizationOperationContent((0, import_node_fs9.readFileSync)(path2, "utf8"));
|
|
49593
49524
|
}
|
|
49594
49525
|
function readDeviceAuthorizationOperation() {
|
|
49595
49526
|
const path2 = deviceAuthorizationOperationPath();
|
|
49596
|
-
if (!(0,
|
|
49597
|
-
const parsed = parseDeviceAuthorizationOperationContent((0,
|
|
49527
|
+
if (!(0, import_node_fs9.existsSync)(path2)) return null;
|
|
49528
|
+
const parsed = parseDeviceAuthorizationOperationContent((0, import_node_fs9.readFileSync)(path2, "utf8"));
|
|
49598
49529
|
const lease = parsed ?? quarantineCorruptDeviceAuthorizationOperation(path2);
|
|
49599
49530
|
if (!lease) return null;
|
|
49600
49531
|
if (lease.expiresAtMs <= Date.now()) {
|
|
@@ -49612,10 +49543,10 @@ function acquireDeviceAuthorizationOperation() {
|
|
|
49612
49543
|
expiresAtMs: Date.now() + 6e4
|
|
49613
49544
|
};
|
|
49614
49545
|
const path2 = deviceAuthorizationOperationPath();
|
|
49615
|
-
(0,
|
|
49546
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(path2), { recursive: true, mode: 448 });
|
|
49616
49547
|
try {
|
|
49617
|
-
(0,
|
|
49618
|
-
(0,
|
|
49548
|
+
(0, import_node_fs9.writeFileSync)(path2, JSON.stringify(lease), { mode: 384, flag: "wx" });
|
|
49549
|
+
(0, import_node_fs9.chmodSync)(path2, 384);
|
|
49619
49550
|
return lease;
|
|
49620
49551
|
} catch (error61) {
|
|
49621
49552
|
if (error61.code === "EEXIST") return null;
|
|
@@ -49630,15 +49561,15 @@ function extendDeviceAuthorizationOperation(operationId, expiresAtMs) {
|
|
|
49630
49561
|
const path2 = deviceAuthorizationOperationPath();
|
|
49631
49562
|
const pendingPath = `${path2}.pending-${process.pid}-${(0, import_node_crypto5.randomBytes)(6).toString("hex")}`;
|
|
49632
49563
|
try {
|
|
49633
|
-
(0,
|
|
49564
|
+
(0, import_node_fs9.writeFileSync)(
|
|
49634
49565
|
pendingPath,
|
|
49635
49566
|
JSON.stringify({ ...current, expiresAtMs: Math.max(expiresAtMs, Date.now() + 6e4) }),
|
|
49636
49567
|
{ mode: 384 }
|
|
49637
49568
|
);
|
|
49638
|
-
(0,
|
|
49639
|
-
(0,
|
|
49569
|
+
(0, import_node_fs9.chmodSync)(pendingPath, 384);
|
|
49570
|
+
(0, import_node_fs9.renameSync)(pendingPath, path2);
|
|
49640
49571
|
} finally {
|
|
49641
|
-
(0,
|
|
49572
|
+
(0, import_node_fs9.rmSync)(pendingPath, { force: true });
|
|
49642
49573
|
}
|
|
49643
49574
|
}
|
|
49644
49575
|
function assertDeviceAuthorizationOperationOwner(operationId) {
|
|
@@ -49649,12 +49580,12 @@ function assertDeviceAuthorizationOperationOwner(operationId) {
|
|
|
49649
49580
|
function clearPendingDeviceAuthorization(operationId) {
|
|
49650
49581
|
const path2 = pendingDeviceAuthorizationPath();
|
|
49651
49582
|
if (!operationId) {
|
|
49652
|
-
(0,
|
|
49583
|
+
(0, import_node_fs9.rmSync)(path2, { force: true });
|
|
49653
49584
|
return;
|
|
49654
49585
|
}
|
|
49655
|
-
if (!(0,
|
|
49586
|
+
if (!(0, import_node_fs9.existsSync)(path2)) return;
|
|
49656
49587
|
try {
|
|
49657
|
-
const pending = JSON.parse((0,
|
|
49588
|
+
const pending = JSON.parse((0, import_node_fs9.readFileSync)(path2, "utf8"));
|
|
49658
49589
|
if (pending.operationId !== operationId) return;
|
|
49659
49590
|
} catch {
|
|
49660
49591
|
return;
|
|
@@ -49663,9 +49594,9 @@ function clearPendingDeviceAuthorization(operationId) {
|
|
|
49663
49594
|
}
|
|
49664
49595
|
function readPendingDeviceAuthorization(apiUrl) {
|
|
49665
49596
|
const path2 = pendingDeviceAuthorizationPath();
|
|
49666
|
-
if (!(0,
|
|
49597
|
+
if (!(0, import_node_fs9.existsSync)(path2)) return null;
|
|
49667
49598
|
try {
|
|
49668
|
-
const pending = JSON.parse((0,
|
|
49599
|
+
const pending = JSON.parse((0, import_node_fs9.readFileSync)(path2, "utf8"));
|
|
49669
49600
|
const expiresAtMs = Date.parse(pending.expiresAt ?? "");
|
|
49670
49601
|
if (pending.apiUrl !== apiUrl || typeof pending.deviceCode !== "string" || typeof pending.userCode !== "string" || typeof pending.verificationUri !== "string" || typeof pending.installationId !== "string" || pending.operationId !== void 0 && typeof pending.operationId !== "string" || !Number.isFinite(pending.intervalSeconds) || !Number.isFinite(expiresAtMs) || expiresAtMs <= Date.now()) {
|
|
49671
49602
|
return null;
|
|
@@ -49677,20 +49608,20 @@ function readPendingDeviceAuthorization(apiUrl) {
|
|
|
49677
49608
|
}
|
|
49678
49609
|
function writePendingDeviceAuthorization(pending) {
|
|
49679
49610
|
const path2 = pendingDeviceAuthorizationPath();
|
|
49680
|
-
(0,
|
|
49611
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(path2), { recursive: true, mode: 448 });
|
|
49681
49612
|
const writePath = `${path2}.pending-${process.pid}-${(0, import_node_crypto5.randomBytes)(6).toString("hex")}`;
|
|
49682
49613
|
try {
|
|
49683
|
-
(0,
|
|
49684
|
-
(0,
|
|
49685
|
-
(0,
|
|
49614
|
+
(0, import_node_fs9.writeFileSync)(writePath, JSON.stringify(pending, null, 2), { mode: 384 });
|
|
49615
|
+
(0, import_node_fs9.chmodSync)(writePath, 384);
|
|
49616
|
+
(0, import_node_fs9.renameSync)(writePath, path2);
|
|
49686
49617
|
} finally {
|
|
49687
|
-
(0,
|
|
49618
|
+
(0, import_node_fs9.rmSync)(writePath, { force: true });
|
|
49688
49619
|
}
|
|
49689
49620
|
}
|
|
49690
49621
|
function removeAlanOwnedLocalArtifacts() {
|
|
49691
49622
|
const configPath = getConfigPath();
|
|
49692
|
-
const directory = (0,
|
|
49693
|
-
const configName = (0,
|
|
49623
|
+
const directory = (0, import_node_path10.dirname)(configPath);
|
|
49624
|
+
const configName = (0, import_node_path10.basename)(configPath).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
49694
49625
|
const alanAtomicSidecarPattern = new RegExp(
|
|
49695
49626
|
`^${configName}(?:|\\.setup-pending|\\.device-auth-pending|\\.device-auth-operation\\.json|\\.maintenance-lease\\.json|\\.event-outbox\\.enc)\\.(?:pending|release|corrupt)-\\d+-[a-f0-9]{12}$`
|
|
49696
49627
|
);
|
|
@@ -49707,19 +49638,26 @@ function removeAlanOwnedLocalArtifacts() {
|
|
|
49707
49638
|
`${configPath}.pending-runs.json.pending`,
|
|
49708
49639
|
maintenanceLeasePath(configPath)
|
|
49709
49640
|
]);
|
|
49710
|
-
if ((0,
|
|
49711
|
-
for (const entry of (0,
|
|
49712
|
-
if (alanAtomicSidecarPattern.test(entry)) artifacts.add((0,
|
|
49641
|
+
if ((0, import_node_fs9.existsSync)(directory)) {
|
|
49642
|
+
for (const entry of (0, import_node_fs9.readdirSync)(directory)) {
|
|
49643
|
+
if (alanAtomicSidecarPattern.test(entry)) artifacts.add((0, import_node_path10.join)(directory, entry));
|
|
49713
49644
|
}
|
|
49714
49645
|
}
|
|
49715
|
-
for (const artifact of artifacts) (0,
|
|
49716
|
-
|
|
49646
|
+
for (const artifact of artifacts) (0, import_node_fs9.rmSync)(artifact, { force: true });
|
|
49647
|
+
for (const encryptedDirectory of [
|
|
49648
|
+
`${configPath}.event-outbox.enc.journal`,
|
|
49649
|
+
`${configPath}.native-streams`,
|
|
49650
|
+
(0, import_node_path10.join)(directory, "native-hook-inbox")
|
|
49651
|
+
]) {
|
|
49652
|
+
(0, import_node_fs9.rmSync)(encryptedDirectory, { recursive: true, force: true });
|
|
49653
|
+
}
|
|
49654
|
+
(0, import_node_fs9.rmSync)(configPath, { force: true });
|
|
49717
49655
|
}
|
|
49718
49656
|
|
|
49719
49657
|
// src/provider-model-discovery.ts
|
|
49720
|
-
var
|
|
49658
|
+
var import_node_fs10 = require("fs");
|
|
49721
49659
|
var import_node_os6 = require("os");
|
|
49722
|
-
var
|
|
49660
|
+
var import_node_path11 = require("path");
|
|
49723
49661
|
var MODEL_DISCOVERY_TIMEOUT_MS = 8e3;
|
|
49724
49662
|
var ANTIGRAVITY_MODEL_DISCOVERY_TIMEOUT_MS = 12e3;
|
|
49725
49663
|
var OPENCODE_ZEN_MODEL_IDS = OPENCODE_ZEN_MODELS.map((model) => model.id);
|
|
@@ -49931,7 +49869,7 @@ function filterClaudeDatedModelIds(ids) {
|
|
|
49931
49869
|
}
|
|
49932
49870
|
function resolveExecutableForModelScan(executable) {
|
|
49933
49871
|
try {
|
|
49934
|
-
return (0,
|
|
49872
|
+
return (0, import_node_fs10.realpathSync)(executable);
|
|
49935
49873
|
} catch {
|
|
49936
49874
|
return executable;
|
|
49937
49875
|
}
|
|
@@ -49939,7 +49877,7 @@ function resolveExecutableForModelScan(executable) {
|
|
|
49939
49877
|
function extractClaudeModelIdsFromExecutable(executable) {
|
|
49940
49878
|
try {
|
|
49941
49879
|
const resolved = resolveExecutableForModelScan(executable);
|
|
49942
|
-
const text = (0,
|
|
49880
|
+
const text = (0, import_node_fs10.readFileSync)(resolved).toString("latin1");
|
|
49943
49881
|
const matches = text.match(CLAUDE_MODEL_ID_PATTERN) ?? [];
|
|
49944
49882
|
const unique2 = [
|
|
49945
49883
|
...new Set(matches.map((id) => id.trim()).filter((id) => isValidClaudeModelId(id))),
|
|
@@ -49998,9 +49936,9 @@ function readOpenCodeZenCredential(env) {
|
|
|
49998
49936
|
function readOpenCodeAuthDocument(env) {
|
|
49999
49937
|
const injected = env.OPENCODE_AUTH_CONTENT?.trim();
|
|
50000
49938
|
if (injected) return injected;
|
|
50001
|
-
const dataHome = env.XDG_DATA_HOME?.trim() || (0,
|
|
49939
|
+
const dataHome = env.XDG_DATA_HOME?.trim() || (0, import_node_path11.join)((0, import_node_os6.homedir)(), ".local", "share");
|
|
50002
49940
|
try {
|
|
50003
|
-
return (0,
|
|
49941
|
+
return (0, import_node_fs10.readFileSync)((0, import_node_path11.join)(dataHome, "opencode", "auth.json"), "utf8");
|
|
50004
49942
|
} catch {
|
|
50005
49943
|
return null;
|
|
50006
49944
|
}
|
|
@@ -50083,11 +50021,11 @@ function applyZenEntitlement(discovery, entitled) {
|
|
|
50083
50021
|
var OPENCODE_CATALOGUE_CACHE_SEGMENTS = ["opencode", "models.json"];
|
|
50084
50022
|
var OPENCODE_CACHE_PROVIDER_KEYS = ["opencode", "opencode-go"];
|
|
50085
50023
|
function readOpenCodeCatalogueCache(env) {
|
|
50086
|
-
const cacheHome = env.XDG_CACHE_HOME?.trim() || (0,
|
|
50024
|
+
const cacheHome = env.XDG_CACHE_HOME?.trim() || (0, import_node_path11.join)((0, import_node_os6.homedir)(), ".cache");
|
|
50087
50025
|
let parsed;
|
|
50088
50026
|
try {
|
|
50089
50027
|
parsed = JSON.parse(
|
|
50090
|
-
(0,
|
|
50028
|
+
(0, import_node_fs10.readFileSync)((0, import_node_path11.join)(cacheHome, ...OPENCODE_CATALOGUE_CACHE_SEGMENTS), "utf8")
|
|
50091
50029
|
);
|
|
50092
50030
|
} catch {
|
|
50093
50031
|
return null;
|
|
@@ -54250,11 +54188,11 @@ Object.assign(lookup, {
|
|
|
54250
54188
|
});
|
|
54251
54189
|
|
|
54252
54190
|
// src/binding-switch-git.ts
|
|
54253
|
-
var
|
|
54191
|
+
var import_node_child_process6 = require("child_process");
|
|
54254
54192
|
var import_node_crypto6 = require("crypto");
|
|
54255
|
-
var
|
|
54193
|
+
var import_node_fs11 = require("fs");
|
|
54256
54194
|
var import_node_os7 = require("os");
|
|
54257
|
-
var
|
|
54195
|
+
var import_node_path12 = require("path");
|
|
54258
54196
|
var import_node_url = require("url");
|
|
54259
54197
|
var BINDING_SWITCH_GIT_METHODS = [
|
|
54260
54198
|
"git.status",
|
|
@@ -54279,7 +54217,7 @@ var LOCAL_GIT_TIMEOUT_MS = 1e4;
|
|
|
54279
54217
|
var NETWORK_GIT_TIMEOUT_MS = 3e4;
|
|
54280
54218
|
var MAX_GIT_OUTPUT_BYTES = 10 * 1024 * 1024;
|
|
54281
54219
|
function runGitResult(cwd, args, options = {}) {
|
|
54282
|
-
const result = (0,
|
|
54220
|
+
const result = (0, import_node_child_process6.spawnSync)("git", args, {
|
|
54283
54221
|
cwd,
|
|
54284
54222
|
env: { ...getDaemonCliEnvironment(), ...options.env },
|
|
54285
54223
|
encoding: "utf8",
|
|
@@ -54304,12 +54242,12 @@ function networkGitTimeoutMs() {
|
|
|
54304
54242
|
async function waitForCheckpointTestBarrier() {
|
|
54305
54243
|
const barrierDir = process.env.NODE_ENV === "test" ? process.env.ALAN_TEST_GIT_CHECKPOINT_BARRIER_DIR : void 0;
|
|
54306
54244
|
if (!barrierDir) return;
|
|
54307
|
-
(0,
|
|
54308
|
-
const readyPath = (0,
|
|
54309
|
-
const releasePath = (0,
|
|
54310
|
-
(0,
|
|
54245
|
+
(0, import_node_fs11.mkdirSync)(barrierDir, { recursive: true });
|
|
54246
|
+
const readyPath = (0, import_node_path12.join)(barrierDir, "ready");
|
|
54247
|
+
const releasePath = (0, import_node_path12.join)(barrierDir, "release");
|
|
54248
|
+
(0, import_node_fs11.writeFileSync)(readyPath, "ready\n");
|
|
54311
54249
|
const deadline = Date.now() + 5e3;
|
|
54312
|
-
while (!(0,
|
|
54250
|
+
while (!(0, import_node_fs11.existsSync)(releasePath)) {
|
|
54313
54251
|
if (Date.now() >= deadline) {
|
|
54314
54252
|
throw new BindingSwitchGitError(
|
|
54315
54253
|
"checkpoint_prepare_timeout",
|
|
@@ -54322,12 +54260,12 @@ async function waitForCheckpointTestBarrier() {
|
|
|
54322
54260
|
async function waitForCheckpointFinalizeTestBarrier() {
|
|
54323
54261
|
const barrierDir = process.env.NODE_ENV === "test" ? process.env.ALAN_TEST_GIT_CHECKPOINT_FINALIZE_BARRIER_DIR : void 0;
|
|
54324
54262
|
if (!barrierDir) return;
|
|
54325
|
-
(0,
|
|
54326
|
-
const readyPath = (0,
|
|
54327
|
-
const releasePath = (0,
|
|
54328
|
-
(0,
|
|
54263
|
+
(0, import_node_fs11.mkdirSync)(barrierDir, { recursive: true });
|
|
54264
|
+
const readyPath = (0, import_node_path12.join)(barrierDir, "ready");
|
|
54265
|
+
const releasePath = (0, import_node_path12.join)(barrierDir, "release");
|
|
54266
|
+
(0, import_node_fs11.writeFileSync)(readyPath, "ready\n");
|
|
54329
54267
|
const deadline = Date.now() + 5e3;
|
|
54330
|
-
while (!(0,
|
|
54268
|
+
while (!(0, import_node_fs11.existsSync)(releasePath)) {
|
|
54331
54269
|
if (Date.now() >= deadline) {
|
|
54332
54270
|
throw new BindingSwitchGitError(
|
|
54333
54271
|
"checkpoint_finalize_timeout",
|
|
@@ -54339,7 +54277,7 @@ async function waitForCheckpointFinalizeTestBarrier() {
|
|
|
54339
54277
|
}
|
|
54340
54278
|
async function runNetworkGit(cwd, args, code) {
|
|
54341
54279
|
return new Promise((resolvePromise, rejectPromise) => {
|
|
54342
|
-
const child = (0,
|
|
54280
|
+
const child = (0, import_node_child_process6.spawn)("git", args, {
|
|
54343
54281
|
cwd,
|
|
54344
54282
|
env: {
|
|
54345
54283
|
...getDaemonCliEnvironment(),
|
|
@@ -54440,7 +54378,7 @@ function sourceChangedDuringCheckpoint(message) {
|
|
|
54440
54378
|
}
|
|
54441
54379
|
function acquireCheckpointHeadLock(locks) {
|
|
54442
54380
|
try {
|
|
54443
|
-
(0,
|
|
54381
|
+
(0, import_node_fs11.writeFileSync)(locks.headLockPath, "", { flag: "wx" });
|
|
54444
54382
|
locks.headLockHeld = true;
|
|
54445
54383
|
} catch {
|
|
54446
54384
|
throw sourceChangedDuringCheckpoint(
|
|
@@ -54450,7 +54388,7 @@ function acquireCheckpointHeadLock(locks) {
|
|
|
54450
54388
|
}
|
|
54451
54389
|
function releaseCheckpointHeadLock(locks) {
|
|
54452
54390
|
if (!locks.headLockHeld) return;
|
|
54453
|
-
(0,
|
|
54391
|
+
(0, import_node_fs11.rmSync)(locks.headLockPath, { force: true });
|
|
54454
54392
|
locks.headLockHeld = false;
|
|
54455
54393
|
}
|
|
54456
54394
|
function acquireCheckpointRepositoryLocks(repoRoot) {
|
|
@@ -54465,20 +54403,20 @@ function acquireCheckpointRepositoryLocks(repoRoot) {
|
|
|
54465
54403
|
"checkpoint_lock_unavailable"
|
|
54466
54404
|
);
|
|
54467
54405
|
const locks = {
|
|
54468
|
-
headLockPath: (0,
|
|
54406
|
+
headLockPath: (0, import_node_path12.join)(gitDir, "HEAD.lock"),
|
|
54469
54407
|
headLockHeld: false,
|
|
54470
54408
|
indexLockPath: `${indexPath}.lock`,
|
|
54471
54409
|
indexLockHeld: false,
|
|
54472
54410
|
indexPath
|
|
54473
54411
|
};
|
|
54474
54412
|
try {
|
|
54475
|
-
(0,
|
|
54413
|
+
(0, import_node_fs11.writeFileSync)(locks.indexLockPath, "", { flag: "wx" });
|
|
54476
54414
|
locks.indexLockHeld = true;
|
|
54477
54415
|
acquireCheckpointHeadLock(locks);
|
|
54478
54416
|
return locks;
|
|
54479
54417
|
} catch {
|
|
54480
54418
|
if (locks.indexLockHeld) {
|
|
54481
|
-
(0,
|
|
54419
|
+
(0, import_node_fs11.rmSync)(locks.indexLockPath, { force: true });
|
|
54482
54420
|
locks.indexLockHeld = false;
|
|
54483
54421
|
}
|
|
54484
54422
|
throw sourceChangedDuringCheckpoint(
|
|
@@ -54489,7 +54427,7 @@ function acquireCheckpointRepositoryLocks(repoRoot) {
|
|
|
54489
54427
|
function releaseCheckpointRepositoryLocks(locks) {
|
|
54490
54428
|
releaseCheckpointHeadLock(locks);
|
|
54491
54429
|
if (locks.indexLockHeld) {
|
|
54492
|
-
(0,
|
|
54430
|
+
(0, import_node_fs11.rmSync)(locks.indexLockPath, { force: true });
|
|
54493
54431
|
locks.indexLockHeld = false;
|
|
54494
54432
|
}
|
|
54495
54433
|
}
|
|
@@ -54507,8 +54445,8 @@ function assertCheckpointHead(repoRoot, expectedRef, expectedHeadSha) {
|
|
|
54507
54445
|
}
|
|
54508
54446
|
}
|
|
54509
54447
|
function createCheckpointIndexBaseline(repoRoot, checkpointSha) {
|
|
54510
|
-
const tempDir = (0,
|
|
54511
|
-
const indexPath = (0,
|
|
54448
|
+
const tempDir = (0, import_node_fs11.mkdtempSync)((0, import_node_path12.join)((0, import_node_os7.tmpdir)(), "alan-checkpoint-index-"));
|
|
54449
|
+
const indexPath = (0, import_node_path12.join)(tempDir, "index");
|
|
54512
54450
|
try {
|
|
54513
54451
|
runGitWithOptions(
|
|
54514
54452
|
repoRoot,
|
|
@@ -54518,14 +54456,14 @@ function createCheckpointIndexBaseline(repoRoot, checkpointSha) {
|
|
|
54518
54456
|
);
|
|
54519
54457
|
return { indexPath, tempDir };
|
|
54520
54458
|
} catch (error61) {
|
|
54521
|
-
(0,
|
|
54459
|
+
(0, import_node_fs11.rmSync)(tempDir, { recursive: true, force: true });
|
|
54522
54460
|
throw error61;
|
|
54523
54461
|
}
|
|
54524
54462
|
}
|
|
54525
54463
|
function installCheckpointIndexBaseline(locks, baselineIndexPath) {
|
|
54526
54464
|
try {
|
|
54527
|
-
(0,
|
|
54528
|
-
(0,
|
|
54465
|
+
(0, import_node_fs11.copyFileSync)(baselineIndexPath, locks.indexLockPath);
|
|
54466
|
+
(0, import_node_fs11.renameSync)(locks.indexLockPath, locks.indexPath);
|
|
54529
54467
|
locks.indexLockHeld = false;
|
|
54530
54468
|
} catch (error61) {
|
|
54531
54469
|
throw new BindingSwitchGitError(
|
|
@@ -54569,7 +54507,7 @@ function commonRequest(params) {
|
|
|
54569
54507
|
return {
|
|
54570
54508
|
switchId: requiredString2(params, "switchId"),
|
|
54571
54509
|
repoKey: requiredString2(params, "repoKey"),
|
|
54572
|
-
repoPath: (0,
|
|
54510
|
+
repoPath: (0, import_node_path12.resolve)(requiredString2(params, "repoPath"))
|
|
54573
54511
|
};
|
|
54574
54512
|
}
|
|
54575
54513
|
function assertCommitSha(sha, key) {
|
|
@@ -54581,7 +54519,7 @@ function assertValidBranch(branch) {
|
|
|
54581
54519
|
if (branch.startsWith("-")) {
|
|
54582
54520
|
throw new BindingSwitchGitError("invalid_git_request", "branch is not a safe Git ref");
|
|
54583
54521
|
}
|
|
54584
|
-
const result = (0,
|
|
54522
|
+
const result = (0, import_node_child_process6.spawnSync)("git", ["check-ref-format", "--branch", branch], {
|
|
54585
54523
|
env: getDaemonCliEnvironment(),
|
|
54586
54524
|
encoding: "utf8"
|
|
54587
54525
|
});
|
|
@@ -54603,8 +54541,8 @@ function canonicalRemoteUrl(repoRoot, value2) {
|
|
|
54603
54541
|
}
|
|
54604
54542
|
const scpStyle = trimmed.match(/^([^/@:\s]+)@([^/:\s]+):(.+)$/);
|
|
54605
54543
|
const urlValue = scpStyle ? `ssh://${scpStyle[1]}@${scpStyle[2]}/${scpStyle[3]}` : trimmed;
|
|
54606
|
-
if ((0,
|
|
54607
|
-
const absolute = (0,
|
|
54544
|
+
if ((0, import_node_path12.isAbsolute)(urlValue) || urlValue.startsWith("./") || urlValue.startsWith("../")) {
|
|
54545
|
+
const absolute = (0, import_node_path12.isAbsolute)(urlValue) ? urlValue : (0, import_node_path12.resolve)(repoRoot, urlValue);
|
|
54608
54546
|
return `file://${canonicalPathWithMissingTail(absolute).replace(/\/+$/, "").replace(/\.git$/, "")}`;
|
|
54609
54547
|
}
|
|
54610
54548
|
let parsed;
|
|
@@ -54671,22 +54609,22 @@ function inspectedRemoteUrl(repoRoot, params) {
|
|
|
54671
54609
|
}
|
|
54672
54610
|
function canonicalPathWithMissingTail(path2) {
|
|
54673
54611
|
const missingSegments = [];
|
|
54674
|
-
let cursor2 = (0,
|
|
54675
|
-
while (!(0,
|
|
54676
|
-
const parent = (0,
|
|
54612
|
+
let cursor2 = (0, import_node_path12.resolve)(path2);
|
|
54613
|
+
while (!(0, import_node_fs11.existsSync)(cursor2)) {
|
|
54614
|
+
const parent = (0, import_node_path12.dirname)(cursor2);
|
|
54677
54615
|
if (parent === cursor2) {
|
|
54678
54616
|
throw new BindingSwitchGitError(
|
|
54679
54617
|
"path_canonicalization_failed",
|
|
54680
54618
|
"The selected path has no existing canonical ancestor"
|
|
54681
54619
|
);
|
|
54682
54620
|
}
|
|
54683
|
-
missingSegments.unshift((0,
|
|
54621
|
+
missingSegments.unshift((0, import_node_path12.basename)(cursor2));
|
|
54684
54622
|
cursor2 = parent;
|
|
54685
54623
|
}
|
|
54686
|
-
return (0,
|
|
54624
|
+
return (0, import_node_path12.join)(import_node_fs11.realpathSync.native(cursor2), ...missingSegments);
|
|
54687
54625
|
}
|
|
54688
54626
|
function resolveRepositoryRoot(requestedPath) {
|
|
54689
|
-
if (!(0,
|
|
54627
|
+
if (!(0, import_node_fs11.existsSync)(requestedPath)) {
|
|
54690
54628
|
throw new BindingSwitchGitError(
|
|
54691
54629
|
"repository_not_found",
|
|
54692
54630
|
`The selected repository path does not exist: ${requestedPath}`
|
|
@@ -54699,7 +54637,7 @@ function resolveRepositoryRoot(requestedPath) {
|
|
|
54699
54637
|
"The selected folder is not inside a Git repository"
|
|
54700
54638
|
);
|
|
54701
54639
|
}
|
|
54702
|
-
return
|
|
54640
|
+
return import_node_fs11.realpathSync.native((0, import_node_path12.resolve)(root.stdout.trim()));
|
|
54703
54641
|
}
|
|
54704
54642
|
function listWorktrees(repoRoot) {
|
|
54705
54643
|
return runGit(repoRoot, ["worktree", "list", "--porcelain"]).split("\n\n").flatMap((entry) => {
|
|
@@ -54718,7 +54656,7 @@ function resolveAuthorizedRepository(params, requireTrustedContext = false) {
|
|
|
54718
54656
|
const { repoPath } = commonRequest(params);
|
|
54719
54657
|
const repoRoot = resolveRepositoryRoot(repoPath);
|
|
54720
54658
|
const expectedRepoRoot = requireTrustedContext ? requiredString2(params, "expectedRepoRoot") : optionalString(params, "expectedRepoRoot");
|
|
54721
|
-
if (expectedRepoRoot && resolveRepositoryRoot((0,
|
|
54659
|
+
if (expectedRepoRoot && resolveRepositoryRoot((0, import_node_path12.resolve)(expectedRepoRoot)) !== repoRoot) {
|
|
54722
54660
|
throw new BindingSwitchGitError(
|
|
54723
54661
|
"repository_path_changed",
|
|
54724
54662
|
"The selected path now resolves to a different Git repository"
|
|
@@ -54726,7 +54664,7 @@ function resolveAuthorizedRepository(params, requireTrustedContext = false) {
|
|
|
54726
54664
|
}
|
|
54727
54665
|
const projectPath = requireTrustedContext ? requiredString2(params, "projectPath") : optionalString(params, "projectPath");
|
|
54728
54666
|
if (!projectPath) return repoRoot;
|
|
54729
|
-
const projectRoot = resolveRepositoryRoot((0,
|
|
54667
|
+
const projectRoot = resolveRepositoryRoot((0, import_node_path12.resolve)(projectPath));
|
|
54730
54668
|
const registrations = listWorktrees(projectRoot);
|
|
54731
54669
|
const registered = registrations.find(({ path: path2 }) => path2 === repoRoot);
|
|
54732
54670
|
if (!registered) {
|
|
@@ -54755,8 +54693,8 @@ function updateLengthPrefixed(hash2, value2) {
|
|
|
54755
54693
|
hash2.update("\0");
|
|
54756
54694
|
}
|
|
54757
54695
|
function proposedTreeSha(repoRoot, headSha) {
|
|
54758
|
-
const tempDir = (0,
|
|
54759
|
-
const indexPath = (0,
|
|
54696
|
+
const tempDir = (0, import_node_fs11.mkdtempSync)((0, import_node_path12.join)((0, import_node_os7.tmpdir)(), "alan-switch-index-"));
|
|
54697
|
+
const indexPath = (0, import_node_path12.join)(tempDir, "index");
|
|
54760
54698
|
const options = { env: { GIT_INDEX_FILE: indexPath } };
|
|
54761
54699
|
try {
|
|
54762
54700
|
if (headSha) {
|
|
@@ -54769,7 +54707,7 @@ function proposedTreeSha(repoRoot, headSha) {
|
|
|
54769
54707
|
assertCommitSha(treeSha, "proposedTreeSha");
|
|
54770
54708
|
return treeSha;
|
|
54771
54709
|
} finally {
|
|
54772
|
-
(0,
|
|
54710
|
+
(0, import_node_fs11.rmSync)(tempDir, { recursive: true, force: true });
|
|
54773
54711
|
}
|
|
54774
54712
|
}
|
|
54775
54713
|
function statusFingerprint(repoRoot, porcelain, proposedTree) {
|
|
@@ -54905,7 +54843,7 @@ async function checkpoint(params) {
|
|
|
54905
54843
|
return { repoRoot, sha: status.headSha, replayed: true };
|
|
54906
54844
|
} finally {
|
|
54907
54845
|
if (locks2) releaseCheckpointRepositoryLocks(locks2);
|
|
54908
|
-
(0,
|
|
54846
|
+
(0, import_node_fs11.rmSync)(baseline2.tempDir, { recursive: true, force: true });
|
|
54909
54847
|
}
|
|
54910
54848
|
}
|
|
54911
54849
|
assertSourcePreconditions(status, expectedHeadSha, expectedStatusFingerprint, expectedBranch);
|
|
@@ -55013,7 +54951,7 @@ Alan-Repository-Id: ${repoKey}`;
|
|
|
55013
54951
|
runGitResult(repoRoot, ["update-ref", expectedRef, expectedHeadSha, sha]);
|
|
55014
54952
|
}
|
|
55015
54953
|
if (locks) releaseCheckpointRepositoryLocks(locks);
|
|
55016
|
-
(0,
|
|
54954
|
+
(0, import_node_fs11.rmSync)(baseline.tempDir, { recursive: true, force: true });
|
|
55017
54955
|
}
|
|
55018
54956
|
}
|
|
55019
54957
|
function resolveRemoteBranch(repoRoot, params) {
|
|
@@ -55251,10 +55189,10 @@ var import_node_fs15 = require("fs");
|
|
|
55251
55189
|
var import_node_path16 = require("path");
|
|
55252
55190
|
|
|
55253
55191
|
// src/cli-ensure-install.ts
|
|
55254
|
-
var
|
|
55255
|
-
var
|
|
55192
|
+
var import_node_child_process7 = require("child_process");
|
|
55193
|
+
var import_node_fs12 = require("fs");
|
|
55256
55194
|
var import_node_os8 = require("os");
|
|
55257
|
-
var
|
|
55195
|
+
var import_node_path13 = require("path");
|
|
55258
55196
|
var CLI_RUNTIME_VERSIONS_ENV = "ALAN_CLI_RUNTIME_VERSIONS";
|
|
55259
55197
|
var installOutcomes = /* @__PURE__ */ new Map();
|
|
55260
55198
|
function canInstallProviderCli(backendKind) {
|
|
@@ -55271,14 +55209,14 @@ function currentRuntimePlatform() {
|
|
|
55271
55209
|
}
|
|
55272
55210
|
function resolveWindowsNpmInvocation(env, npmArgs) {
|
|
55273
55211
|
const searchPath = env.PATH ?? env.Path ?? "";
|
|
55274
|
-
for (const rawDirectory of searchPath.split(
|
|
55212
|
+
for (const rawDirectory of searchPath.split(import_node_path13.delimiter)) {
|
|
55275
55213
|
const directory = rawDirectory.trim().replace(/^"|"$/g, "");
|
|
55276
55214
|
if (!directory) continue;
|
|
55277
|
-
const executable = (0,
|
|
55278
|
-
if ((0,
|
|
55279
|
-
const commandShim = (0,
|
|
55280
|
-
const cliScript = (0,
|
|
55281
|
-
if ((0,
|
|
55215
|
+
const executable = (0, import_node_path13.join)(directory, "npm.exe");
|
|
55216
|
+
if ((0, import_node_fs12.existsSync)(executable)) return { command: executable, args: npmArgs };
|
|
55217
|
+
const commandShim = (0, import_node_path13.join)(directory, "npm.cmd");
|
|
55218
|
+
const cliScript = (0, import_node_path13.join)(directory, "node_modules", "npm", "bin", "npm-cli.js");
|
|
55219
|
+
if ((0, import_node_fs12.existsSync)(commandShim) && (0, import_node_fs12.existsSync)(cliScript)) {
|
|
55282
55220
|
return { command: process.execPath, args: [cliScript, ...npmArgs] };
|
|
55283
55221
|
}
|
|
55284
55222
|
}
|
|
@@ -55300,7 +55238,7 @@ function runNpmInstall(installSpec, env, timeoutMs) {
|
|
|
55300
55238
|
});
|
|
55301
55239
|
return;
|
|
55302
55240
|
}
|
|
55303
|
-
child = (0,
|
|
55241
|
+
child = (0, import_node_child_process7.spawn)(invocation.command, invocation.args, {
|
|
55304
55242
|
env,
|
|
55305
55243
|
windowsHide: isWin ? true : void 0,
|
|
55306
55244
|
timeout: timeoutMs,
|
|
@@ -55383,25 +55321,25 @@ var import_node_os10 = require("os");
|
|
|
55383
55321
|
|
|
55384
55322
|
// src/antigravity-api-key-config.ts
|
|
55385
55323
|
var import_node_crypto7 = require("crypto");
|
|
55386
|
-
var
|
|
55324
|
+
var import_node_fs13 = require("fs");
|
|
55387
55325
|
var import_node_os9 = require("os");
|
|
55388
|
-
var
|
|
55326
|
+
var import_node_path14 = require("path");
|
|
55389
55327
|
var CONFIG_LOCK_STALE_MS = 3e4;
|
|
55390
55328
|
var CONFIG_LOCK_WAIT_MS = 2e3;
|
|
55391
55329
|
var CONFIG_LOCK_POLL_MS = 20;
|
|
55392
55330
|
async function waitForConfigLock(lockPath) {
|
|
55393
|
-
(0,
|
|
55331
|
+
(0, import_node_fs13.mkdirSync)((0, import_node_path14.dirname)(lockPath), { recursive: true });
|
|
55394
55332
|
const startedAt = Date.now();
|
|
55395
55333
|
while (true) {
|
|
55396
55334
|
try {
|
|
55397
|
-
(0,
|
|
55398
|
-
return () => (0,
|
|
55335
|
+
(0, import_node_fs13.mkdirSync)(lockPath);
|
|
55336
|
+
return () => (0, import_node_fs13.rmSync)(lockPath, { recursive: true, force: true });
|
|
55399
55337
|
} catch (error61) {
|
|
55400
55338
|
const code = error61 && typeof error61 === "object" && "code" in error61 ? error61.code : void 0;
|
|
55401
55339
|
if (code !== "EEXIST") throw error61;
|
|
55402
55340
|
try {
|
|
55403
|
-
if (Date.now() - (0,
|
|
55404
|
-
(0,
|
|
55341
|
+
if (Date.now() - (0, import_node_fs13.statSync)(lockPath).mtimeMs > CONFIG_LOCK_STALE_MS) {
|
|
55342
|
+
(0, import_node_fs13.rmSync)(lockPath, { recursive: true, force: true });
|
|
55405
55343
|
continue;
|
|
55406
55344
|
}
|
|
55407
55345
|
} catch {
|
|
@@ -55424,29 +55362,29 @@ function parseJsonObject2(path2, content) {
|
|
|
55424
55362
|
}
|
|
55425
55363
|
const hash2 = (0, import_node_crypto7.createHash)("sha256").update(content).digest("hex").slice(0, 12);
|
|
55426
55364
|
const backupPath = `${path2}.alan-backup-${hash2}`;
|
|
55427
|
-
if (!(0,
|
|
55365
|
+
if (!(0, import_node_fs13.existsSync)(backupPath)) (0, import_node_fs13.copyFileSync)(path2, backupPath);
|
|
55428
55366
|
throw new Error(
|
|
55429
55367
|
`Existing config is malformed; no changes were applied. Review the backup at ${backupPath}`
|
|
55430
55368
|
);
|
|
55431
55369
|
}
|
|
55432
55370
|
async function configureAntigravityApiKeyMode(home = (0, import_node_os9.homedir)()) {
|
|
55433
|
-
const path2 = (0,
|
|
55371
|
+
const path2 = (0, import_node_path14.join)(home, ".gemini", "antigravity-cli", "settings.json");
|
|
55434
55372
|
const releaseLock = await waitForConfigLock(`${path2}.alan-lock`);
|
|
55435
55373
|
try {
|
|
55436
|
-
const existing = (0,
|
|
55374
|
+
const existing = (0, import_node_fs13.existsSync)(path2) ? (0, import_node_fs13.readFileSync)(path2, "utf8") : "";
|
|
55437
55375
|
const settings = existing.trim() ? parseJsonObject2(path2, existing) : {};
|
|
55438
55376
|
if (settings.modelProvider === "gemini") return false;
|
|
55439
55377
|
settings.modelProvider = "gemini";
|
|
55440
55378
|
const pending = `${path2}.alan-pending-${process.pid}-${(0, import_node_crypto7.randomBytes)(6).toString("hex")}`;
|
|
55441
55379
|
try {
|
|
55442
|
-
(0,
|
|
55380
|
+
(0, import_node_fs13.writeFileSync)(pending, JSON.stringify(settings), {
|
|
55443
55381
|
encoding: "utf8",
|
|
55444
55382
|
mode: 384,
|
|
55445
55383
|
flag: "wx"
|
|
55446
55384
|
});
|
|
55447
|
-
(0,
|
|
55385
|
+
(0, import_node_fs13.renameSync)(pending, path2);
|
|
55448
55386
|
} finally {
|
|
55449
|
-
(0,
|
|
55387
|
+
(0, import_node_fs13.rmSync)(pending, { force: true });
|
|
55450
55388
|
}
|
|
55451
55389
|
return true;
|
|
55452
55390
|
} finally {
|
|
@@ -56286,6 +56224,75 @@ ${input2.userRequest}
|
|
|
56286
56224
|
</user-request>` : instruction;
|
|
56287
56225
|
}
|
|
56288
56226
|
|
|
56227
|
+
// src/workspace-relocation.ts
|
|
56228
|
+
var import_node_child_process8 = require("child_process");
|
|
56229
|
+
var import_node_fs14 = require("fs");
|
|
56230
|
+
var import_node_path15 = require("path");
|
|
56231
|
+
var MAX_RELOCATION_CANDIDATES = 200;
|
|
56232
|
+
var DEFAULT_PROBE2 = {
|
|
56233
|
+
childDirectories: (parentPath, limit) => (0, import_node_fs14.readdirSync)(parentPath, { withFileTypes: true }).filter((entry) => entry.isDirectory()).slice(0, limit).map((entry) => (0, import_node_path15.join)(parentPath, entry.name)),
|
|
56234
|
+
gitRemoteUrl: (candidatePath) => {
|
|
56235
|
+
const result = (0, import_node_child_process8.spawnSync)("git", ["-C", candidatePath, "config", "--get", "remote.origin.url"], {
|
|
56236
|
+
encoding: "utf8",
|
|
56237
|
+
env: getDaemonCliEnvironment(),
|
|
56238
|
+
timeout: 2e3
|
|
56239
|
+
});
|
|
56240
|
+
if (result.status !== 0) return null;
|
|
56241
|
+
const url3 = result.stdout.trim();
|
|
56242
|
+
return url3 || null;
|
|
56243
|
+
}
|
|
56244
|
+
};
|
|
56245
|
+
function normalizeRepositoryIdentity(value2) {
|
|
56246
|
+
const trimmed = value2.trim().replace(/\/+$/, "").replace(/\.git$/i, "");
|
|
56247
|
+
if (!trimmed) return null;
|
|
56248
|
+
const scp = trimmed.match(/^(?:[^@/]+@)?([^:/]+):(.+)$/);
|
|
56249
|
+
if (scp && !trimmed.includes("://")) {
|
|
56250
|
+
return `${scp[1]}/${scp[2]}`.toLowerCase();
|
|
56251
|
+
}
|
|
56252
|
+
try {
|
|
56253
|
+
const url3 = new URL(trimmed);
|
|
56254
|
+
return `${url3.hostname}${url3.pathname}`.replace(/\/+$/, "").toLowerCase();
|
|
56255
|
+
} catch {
|
|
56256
|
+
return null;
|
|
56257
|
+
}
|
|
56258
|
+
}
|
|
56259
|
+
function workspaceMatchesExpectedRepositories(input2) {
|
|
56260
|
+
const identities = new Set(
|
|
56261
|
+
input2.expectedRepoUrls.map(normalizeRepositoryIdentity).filter((identity3) => Boolean(identity3))
|
|
56262
|
+
);
|
|
56263
|
+
if (identities.size === 0) return false;
|
|
56264
|
+
const remote = (input2.probe ?? DEFAULT_PROBE2).gitRemoteUrl((0, import_node_path15.resolve)(input2.workspacePath));
|
|
56265
|
+
const identity2 = remote ? normalizeRepositoryIdentity(remote) : null;
|
|
56266
|
+
return Boolean(identity2 && identities.has(identity2));
|
|
56267
|
+
}
|
|
56268
|
+
function discoverRelocatedWorkspace(input2) {
|
|
56269
|
+
const identities = new Set(
|
|
56270
|
+
input2.expectedRepoUrls.map(normalizeRepositoryIdentity).filter((identity2) => Boolean(identity2))
|
|
56271
|
+
);
|
|
56272
|
+
if (identities.size === 0) return null;
|
|
56273
|
+
const searchRoots = [
|
|
56274
|
+
(0, import_node_path15.dirname)((0, import_node_path15.resolve)(input2.missingPath)),
|
|
56275
|
+
...(input2.approvedWorkspacePaths ?? []).map((path2) => (0, import_node_path15.dirname)((0, import_node_path15.resolve)(path2)))
|
|
56276
|
+
].filter((path2, index, paths) => paths.indexOf(path2) === index);
|
|
56277
|
+
const candidates = [];
|
|
56278
|
+
for (const root of searchRoots) {
|
|
56279
|
+
const remaining = MAX_RELOCATION_CANDIDATES - candidates.length;
|
|
56280
|
+
if (remaining <= 0) break;
|
|
56281
|
+
try {
|
|
56282
|
+
candidates.push(...(input2.probe ?? DEFAULT_PROBE2).childDirectories(root, remaining));
|
|
56283
|
+
} catch {
|
|
56284
|
+
}
|
|
56285
|
+
}
|
|
56286
|
+
const matches = [];
|
|
56287
|
+
for (const candidate of new Set(candidates.map((path2) => (0, import_node_path15.resolve)(path2)))) {
|
|
56288
|
+
const remote = (input2.probe ?? DEFAULT_PROBE2).gitRemoteUrl(candidate);
|
|
56289
|
+
const identity2 = remote ? normalizeRepositoryIdentity(remote) : null;
|
|
56290
|
+
if (identity2 && identities.has(identity2)) matches.push((0, import_node_path15.resolve)(candidate));
|
|
56291
|
+
if (matches.length > 1) return null;
|
|
56292
|
+
}
|
|
56293
|
+
return matches[0] ?? null;
|
|
56294
|
+
}
|
|
56295
|
+
|
|
56289
56296
|
// src/daemon-execute.ts
|
|
56290
56297
|
async function handleAgentExecute(ctx, payload) {
|
|
56291
56298
|
const {
|
|
@@ -64888,6 +64895,9 @@ var McpSyncService = class {
|
|
|
64888
64895
|
cleanup(previousServers = []) {
|
|
64889
64896
|
removeMcpFromAllClis(previousServers);
|
|
64890
64897
|
}
|
|
64898
|
+
uninstall(apiUrl) {
|
|
64899
|
+
this.cleanup(toManagedMcpServers(buildAlanMcpServers(apiUrl)));
|
|
64900
|
+
}
|
|
64891
64901
|
};
|
|
64892
64902
|
|
|
64893
64903
|
// src/native-hook-config.ts
|
|
@@ -66548,7 +66558,9 @@ async function runInstallCommand(commandArgs, currentPlatform = process.platform
|
|
|
66548
66558
|
if (configurationMode === "login") await loginWithDeviceCode(commandArgs);
|
|
66549
66559
|
await installDaemonService(commandArgs);
|
|
66550
66560
|
}
|
|
66551
|
-
|
|
66561
|
+
if (commandArgs.includes("--with-integrations")) {
|
|
66562
|
+
runMcpIntegrationCommand(["reconcile", ...commandArgs]);
|
|
66563
|
+
}
|
|
66552
66564
|
}
|
|
66553
66565
|
|
|
66554
66566
|
// src/lifecycle-logger.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alan-ai-hq/agent-manager",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.112",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Alan agent runtime — cloud sandbox and local daemon (alan-agent CLI)",
|
|
6
6
|
"bin": {
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"tsx": "^4.19.0",
|
|
28
28
|
"typescript": "~5.9.3",
|
|
29
29
|
"@alan-ai/agent-core": "0.1.0",
|
|
30
|
-
"@alan-ai/
|
|
31
|
-
"@alan-ai/
|
|
30
|
+
"@alan-ai/shared": "0.1.0",
|
|
31
|
+
"@alan-ai/sandbox-runtime-spec": "0.1.0"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsup",
|