@alan-ai-hq/agent-manager 0.1.110 → 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 +322 -262
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -14593,6 +14593,15 @@ var SANDBOX_DESKTOP_BROWSER_ENV = Object.freeze({
|
|
|
14593
14593
|
AGENT_BROWSER_NO_XVFB: "1",
|
|
14594
14594
|
AGENT_BROWSER_EXECUTABLE_PATH: "/usr/bin/google-chrome-stable"
|
|
14595
14595
|
});
|
|
14596
|
+
var SANDBOX_GUEST_CLOCK_CHRONY_CONF = [
|
|
14597
|
+
"# Managed by daytona-template/desktop-snapshot.ts (SANDBOX_GUEST_CLOCK_CHRONY_CONF).",
|
|
14598
|
+
"# Memory pauses and hot snapshots resume with the guest clock frozen at capture",
|
|
14599
|
+
"# time. The KVM PTP clock exposes host time without network; makestep -1 lets",
|
|
14600
|
+
"# chronyd step a multi-day offset instead of slewing it for months.",
|
|
14601
|
+
"refclock PHC /dev/ptp0 poll 2 dpoll -2 offset 0 stratum 2 prefer",
|
|
14602
|
+
"makestep 1 -1",
|
|
14603
|
+
""
|
|
14604
|
+
].join("\n");
|
|
14596
14605
|
var definitions = [
|
|
14597
14606
|
{
|
|
14598
14607
|
id: "claude",
|
|
@@ -15234,13 +15243,13 @@ Usage:
|
|
|
15234
15243
|
alan-agent <command> [options]
|
|
15235
15244
|
|
|
15236
15245
|
Commands:
|
|
15237
|
-
install Login/setup
|
|
15246
|
+
install Login/setup and install the daemon service (MCP + session sync are opt-in)
|
|
15238
15247
|
setup Register this computer with a setup token from Alan
|
|
15239
15248
|
login Register this computer through browser authorization
|
|
15240
15249
|
daemon Start the durable runtime daemon
|
|
15241
15250
|
service Install, uninstall, or inspect the per-user daemon service
|
|
15242
|
-
integrations Reconcile, inspect, or uninstall Alan
|
|
15243
|
-
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)
|
|
15244
15253
|
stop Stop the local daemon (or active runs only via the local API /stop)
|
|
15245
15254
|
recover Redial and safely restart a stuck local daemon connection
|
|
15246
15255
|
status Show local runtime configuration without secrets
|
|
@@ -15254,6 +15263,7 @@ Commands:
|
|
|
15254
15263
|
Common flows:
|
|
15255
15264
|
alan-agent install
|
|
15256
15265
|
alan-agent install --setup-token <token>
|
|
15266
|
+
alan-agent install --with-integrations
|
|
15257
15267
|
alan-agent login
|
|
15258
15268
|
alan-agent login --cancel
|
|
15259
15269
|
alan-agent setup --setup-token <token>
|
|
@@ -15537,7 +15547,7 @@ function describeError(error61) {
|
|
|
15537
15547
|
}
|
|
15538
15548
|
|
|
15539
15549
|
// src/version.ts
|
|
15540
|
-
var AGENT_VERSION = "0.1.
|
|
15550
|
+
var AGENT_VERSION = "0.1.112";
|
|
15541
15551
|
|
|
15542
15552
|
// src/daemon-workspace.ts
|
|
15543
15553
|
var import_node_child_process3 = require("child_process");
|
|
@@ -15781,13 +15791,13 @@ function resolveRuntimeCwd(payload) {
|
|
|
15781
15791
|
|
|
15782
15792
|
// src/daemon-local-control.ts
|
|
15783
15793
|
var import_node_crypto5 = require("crypto");
|
|
15784
|
-
var
|
|
15785
|
-
var
|
|
15794
|
+
var import_node_fs9 = require("fs");
|
|
15795
|
+
var import_node_path10 = require("path");
|
|
15786
15796
|
|
|
15787
15797
|
// src/daemon-runner-status.ts
|
|
15788
|
-
var
|
|
15798
|
+
var import_node_fs8 = require("fs");
|
|
15789
15799
|
var import_node_os5 = require("os");
|
|
15790
|
-
var
|
|
15800
|
+
var import_node_path9 = require("path");
|
|
15791
15801
|
|
|
15792
15802
|
// ../shared/dist/node/provider-limits.js
|
|
15793
15803
|
var import_node_child_process4 = require("child_process");
|
|
@@ -35443,6 +35453,16 @@ var WORKFLOW_ALWAYS_ALLOWED_BUILTIN_TOOLS = [
|
|
|
35443
35453
|
"list_prototypes",
|
|
35444
35454
|
"get_prototype"
|
|
35445
35455
|
];
|
|
35456
|
+
var LEGACY_WORKFLOW_BUILTIN_TOOLS = {
|
|
35457
|
+
list_document_comments: "get_document",
|
|
35458
|
+
list_artifact_comments: "get_artifact",
|
|
35459
|
+
list_epic_comments: "get_epic",
|
|
35460
|
+
// Renamed when the thread reply became platform-neutral (Slack + Microsoft Teams).
|
|
35461
|
+
slack_reply_in_thread: "reply_in_thread"
|
|
35462
|
+
};
|
|
35463
|
+
function normalizeWorkflowToolId(id) {
|
|
35464
|
+
return LEGACY_WORKFLOW_BUILTIN_TOOLS[id] ?? id;
|
|
35465
|
+
}
|
|
35446
35466
|
function createWorkflowToolsFilter(workflowTools) {
|
|
35447
35467
|
const hasFilter = !!workflowTools && workflowTools.length > 0;
|
|
35448
35468
|
if (!hasFilter) {
|
|
@@ -35454,7 +35474,7 @@ function createWorkflowToolsFilter(workflowTools) {
|
|
|
35454
35474
|
}
|
|
35455
35475
|
const tools = workflowTools;
|
|
35456
35476
|
const mcpServerIds = new Set(tools.filter((t) => t.type === "mcp").map((t) => t.id));
|
|
35457
|
-
const builtinToolIds = tools.filter((t) => t.type === "builtin" || t.type === "integration").map((t) => t.id);
|
|
35477
|
+
const builtinToolIds = tools.filter((t) => t.type === "builtin" || t.type === "integration").map((t) => normalizeWorkflowToolId(t.id));
|
|
35458
35478
|
return {
|
|
35459
35479
|
hasFilter: true,
|
|
35460
35480
|
isMcpServerAllowed: (serverName) => mcpServerIds.has(serverName),
|
|
@@ -47971,80 +47991,9 @@ ${result.stderr}`.trim();
|
|
|
47971
47991
|
}
|
|
47972
47992
|
|
|
47973
47993
|
// src/workspace-run-lease.ts
|
|
47974
|
-
var import_node_child_process6 = require("child_process");
|
|
47975
|
-
var import_promises5 = require("fs/promises");
|
|
47976
|
-
var import_node_path9 = require("path");
|
|
47977
|
-
|
|
47978
|
-
// src/workspace-relocation.ts
|
|
47979
47994
|
var import_node_child_process5 = require("child_process");
|
|
47980
|
-
var
|
|
47995
|
+
var import_promises5 = require("fs/promises");
|
|
47981
47996
|
var import_node_path8 = require("path");
|
|
47982
|
-
var MAX_RELOCATION_CANDIDATES = 200;
|
|
47983
|
-
var DEFAULT_PROBE = {
|
|
47984
|
-
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)),
|
|
47985
|
-
gitRemoteUrl: (candidatePath) => {
|
|
47986
|
-
const result = (0, import_node_child_process5.spawnSync)("git", ["-C", candidatePath, "config", "--get", "remote.origin.url"], {
|
|
47987
|
-
encoding: "utf8",
|
|
47988
|
-
env: getDaemonCliEnvironment(),
|
|
47989
|
-
timeout: 2e3
|
|
47990
|
-
});
|
|
47991
|
-
if (result.status !== 0) return null;
|
|
47992
|
-
const url3 = result.stdout.trim();
|
|
47993
|
-
return url3 || null;
|
|
47994
|
-
}
|
|
47995
|
-
};
|
|
47996
|
-
function normalizeRepositoryIdentity(value2) {
|
|
47997
|
-
const trimmed = value2.trim().replace(/\/+$/, "").replace(/\.git$/i, "");
|
|
47998
|
-
if (!trimmed) return null;
|
|
47999
|
-
const scp = trimmed.match(/^(?:[^@/]+@)?([^:/]+):(.+)$/);
|
|
48000
|
-
if (scp && !trimmed.includes("://")) {
|
|
48001
|
-
return `${scp[1]}/${scp[2]}`.toLowerCase();
|
|
48002
|
-
}
|
|
48003
|
-
try {
|
|
48004
|
-
const url3 = new URL(trimmed);
|
|
48005
|
-
return `${url3.hostname}${url3.pathname}`.replace(/\/+$/, "").toLowerCase();
|
|
48006
|
-
} catch {
|
|
48007
|
-
return null;
|
|
48008
|
-
}
|
|
48009
|
-
}
|
|
48010
|
-
function workspaceMatchesExpectedRepositories(input2) {
|
|
48011
|
-
const identities = new Set(
|
|
48012
|
-
input2.expectedRepoUrls.map(normalizeRepositoryIdentity).filter((identity3) => Boolean(identity3))
|
|
48013
|
-
);
|
|
48014
|
-
if (identities.size === 0) return false;
|
|
48015
|
-
const remote = (input2.probe ?? DEFAULT_PROBE).gitRemoteUrl((0, import_node_path8.resolve)(input2.workspacePath));
|
|
48016
|
-
const identity2 = remote ? normalizeRepositoryIdentity(remote) : null;
|
|
48017
|
-
return Boolean(identity2 && identities.has(identity2));
|
|
48018
|
-
}
|
|
48019
|
-
function discoverRelocatedWorkspace(input2) {
|
|
48020
|
-
const identities = new Set(
|
|
48021
|
-
input2.expectedRepoUrls.map(normalizeRepositoryIdentity).filter((identity2) => Boolean(identity2))
|
|
48022
|
-
);
|
|
48023
|
-
if (identities.size === 0) return null;
|
|
48024
|
-
const searchRoots = [
|
|
48025
|
-
(0, import_node_path8.dirname)((0, import_node_path8.resolve)(input2.missingPath)),
|
|
48026
|
-
...(input2.approvedWorkspacePaths ?? []).map((path2) => (0, import_node_path8.dirname)((0, import_node_path8.resolve)(path2)))
|
|
48027
|
-
].filter((path2, index, paths) => paths.indexOf(path2) === index);
|
|
48028
|
-
const candidates = [];
|
|
48029
|
-
for (const root of searchRoots) {
|
|
48030
|
-
const remaining = MAX_RELOCATION_CANDIDATES - candidates.length;
|
|
48031
|
-
if (remaining <= 0) break;
|
|
48032
|
-
try {
|
|
48033
|
-
candidates.push(...(input2.probe ?? DEFAULT_PROBE).childDirectories(root, remaining));
|
|
48034
|
-
} catch {
|
|
48035
|
-
}
|
|
48036
|
-
}
|
|
48037
|
-
const matches = [];
|
|
48038
|
-
for (const candidate of new Set(candidates.map((path2) => (0, import_node_path8.resolve)(path2)))) {
|
|
48039
|
-
const remote = (input2.probe ?? DEFAULT_PROBE).gitRemoteUrl(candidate);
|
|
48040
|
-
const identity2 = remote ? normalizeRepositoryIdentity(remote) : null;
|
|
48041
|
-
if (identity2 && identities.has(identity2)) matches.push((0, import_node_path8.resolve)(candidate));
|
|
48042
|
-
if (matches.length > 1) return null;
|
|
48043
|
-
}
|
|
48044
|
-
return matches[0] ?? null;
|
|
48045
|
-
}
|
|
48046
|
-
|
|
48047
|
-
// src/workspace-run-lease.ts
|
|
48048
47997
|
var WORKSPACE_LEASE_CHECK_INTERVAL_MS = 1e3;
|
|
48049
47998
|
function parsePositiveMs(value2, fallback) {
|
|
48050
47999
|
const parsed = value2 ? Number(value2) : Number.NaN;
|
|
@@ -48060,19 +48009,19 @@ function applicationCodeForWorkspaceLeaseFailure(code) {
|
|
|
48060
48009
|
async function hasGitWorkspaceMarker(workspacePath) {
|
|
48061
48010
|
let directory;
|
|
48062
48011
|
try {
|
|
48063
|
-
directory = await (0, import_promises5.realpath)((0,
|
|
48012
|
+
directory = await (0, import_promises5.realpath)((0, import_node_path8.resolve)(workspacePath));
|
|
48064
48013
|
} catch {
|
|
48065
48014
|
return true;
|
|
48066
48015
|
}
|
|
48067
48016
|
while (true) {
|
|
48068
48017
|
try {
|
|
48069
|
-
await (0, import_promises5.stat)((0,
|
|
48018
|
+
await (0, import_promises5.stat)((0, import_node_path8.join)(directory, ".git"));
|
|
48070
48019
|
return true;
|
|
48071
48020
|
} catch (error61) {
|
|
48072
48021
|
const code = error61.code;
|
|
48073
48022
|
if (code !== "ENOENT" && code !== "ENOTDIR") return true;
|
|
48074
48023
|
}
|
|
48075
|
-
const parent = (0,
|
|
48024
|
+
const parent = (0, import_node_path8.dirname)(directory);
|
|
48076
48025
|
if (parent === directory) return false;
|
|
48077
48026
|
directory = parent;
|
|
48078
48027
|
}
|
|
@@ -48084,7 +48033,7 @@ async function gitValue(cwd, args) {
|
|
|
48084
48033
|
else runningGitProbes++;
|
|
48085
48034
|
try {
|
|
48086
48035
|
return await new Promise((resolve16) => {
|
|
48087
|
-
(0,
|
|
48036
|
+
(0, import_node_child_process5.execFile)(
|
|
48088
48037
|
"git",
|
|
48089
48038
|
["-C", cwd, ...args],
|
|
48090
48039
|
{
|
|
@@ -48110,7 +48059,7 @@ async function filesystemIdentity(path2) {
|
|
|
48110
48059
|
return `${canonicalPath}:${metadata.dev}:${metadata.ino}`;
|
|
48111
48060
|
}
|
|
48112
48061
|
function resolveGitPath(workspacePath, value2) {
|
|
48113
|
-
return (0,
|
|
48062
|
+
return (0, import_node_path8.isAbsolute)(value2) ? value2 : (0, import_node_path8.resolve)(workspacePath, value2);
|
|
48114
48063
|
}
|
|
48115
48064
|
function createWorkspaceRunLeaseSnapshotProbe(loadSnapshot) {
|
|
48116
48065
|
const snapshots = /* @__PURE__ */ new Map();
|
|
@@ -48132,7 +48081,7 @@ function createWorkspaceRunLeaseSnapshotProbe(loadSnapshot) {
|
|
|
48132
48081
|
return pending.promise;
|
|
48133
48082
|
};
|
|
48134
48083
|
return (workspacePath, options) => {
|
|
48135
|
-
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);
|
|
48136
48085
|
const existing = snapshots.get(key);
|
|
48137
48086
|
if (!existing) return startSnapshot(key, options?.coalescePending === true);
|
|
48138
48087
|
if (!options?.fresh) return existing.promise;
|
|
@@ -48145,11 +48094,11 @@ function createWorkspaceRunLeaseSnapshotProbe(loadSnapshot) {
|
|
|
48145
48094
|
return existing.freshAfterPending;
|
|
48146
48095
|
};
|
|
48147
48096
|
}
|
|
48148
|
-
var
|
|
48097
|
+
var DEFAULT_PROBE = {
|
|
48149
48098
|
snapshot: createWorkspaceRunLeaseSnapshotProbe(snapshotWorkspace),
|
|
48150
48099
|
pathExists: async (workspacePath) => {
|
|
48151
48100
|
try {
|
|
48152
|
-
await (0, import_promises5.access)((0,
|
|
48101
|
+
await (0, import_promises5.access)((0, import_node_path8.resolve)(workspacePath));
|
|
48153
48102
|
return true;
|
|
48154
48103
|
} catch (error61) {
|
|
48155
48104
|
return error61.code !== "ENOENT";
|
|
@@ -48158,7 +48107,7 @@ var DEFAULT_PROBE2 = {
|
|
|
48158
48107
|
};
|
|
48159
48108
|
async function snapshotWorkspace(workspacePath) {
|
|
48160
48109
|
try {
|
|
48161
|
-
const canonicalWorkspacePath = await (0, import_promises5.realpath)((0,
|
|
48110
|
+
const canonicalWorkspacePath = await (0, import_promises5.realpath)((0, import_node_path8.resolve)(workspacePath));
|
|
48162
48111
|
const repositoryRoot = await gitValue(canonicalWorkspacePath, ["rev-parse", "--show-toplevel"]);
|
|
48163
48112
|
const gitDirectory = await gitValue(canonicalWorkspacePath, ["rev-parse", "--git-dir"]);
|
|
48164
48113
|
const commonDirectory = await gitValue(canonicalWorkspacePath, [
|
|
@@ -48167,14 +48116,15 @@ async function snapshotWorkspace(workspacePath) {
|
|
|
48167
48116
|
]);
|
|
48168
48117
|
const branch = await gitValue(canonicalWorkspacePath, ["branch", "--show-current"]) ?? "";
|
|
48169
48118
|
if (!repositoryRoot || !gitDirectory || !commonDirectory) return null;
|
|
48170
|
-
const remote = await gitValue(canonicalWorkspacePath, ["config", "--get", "remote.origin.url"]);
|
|
48171
|
-
const remoteIdentity = remote ? normalizeRepositoryIdentity(remote) : null;
|
|
48172
48119
|
return {
|
|
48173
|
-
workspacePath: (0,
|
|
48120
|
+
workspacePath: (0, import_node_path8.resolve)(workspacePath),
|
|
48174
48121
|
workspaceIdentity: await filesystemIdentity(canonicalWorkspacePath),
|
|
48175
|
-
|
|
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(
|
|
48176
48126
|
resolveGitPath(canonicalWorkspacePath, commonDirectory)
|
|
48177
|
-
)
|
|
48127
|
+
),
|
|
48178
48128
|
worktreeIdentity: await filesystemIdentity(
|
|
48179
48129
|
resolveGitPath(canonicalWorkspacePath, gitDirectory)
|
|
48180
48130
|
),
|
|
@@ -48210,10 +48160,10 @@ var WorkspaceRunLease = class _WorkspaceRunLease {
|
|
|
48210
48160
|
this.captured = captured;
|
|
48211
48161
|
this.probe = probe;
|
|
48212
48162
|
}
|
|
48213
|
-
static async capture(targets, probe =
|
|
48163
|
+
static async capture(targets, probe = DEFAULT_PROBE) {
|
|
48214
48164
|
const captured = [];
|
|
48215
48165
|
for (const target of targets) {
|
|
48216
|
-
const normalizedTarget = { ...target, workspacePath: (0,
|
|
48166
|
+
const normalizedTarget = { ...target, workspacePath: (0, import_node_path8.resolve)(target.workspacePath) };
|
|
48217
48167
|
const identity2 = await probe.snapshot(normalizedTarget.workspacePath, {
|
|
48218
48168
|
fresh: true,
|
|
48219
48169
|
coalescePending: true
|
|
@@ -48756,13 +48706,13 @@ var DurablePendingRunStarts = class extends Map {
|
|
|
48756
48706
|
}
|
|
48757
48707
|
persist() {
|
|
48758
48708
|
if (this.size === 0) {
|
|
48759
|
-
(0,
|
|
48709
|
+
(0, import_node_fs8.rmSync)(this.path, { force: true });
|
|
48760
48710
|
return;
|
|
48761
48711
|
}
|
|
48762
48712
|
const pendingPath = `${this.path}.pending`;
|
|
48763
|
-
(0,
|
|
48713
|
+
(0, import_node_fs8.mkdirSync)((0, import_node_path9.dirname)(this.path), { recursive: true, mode: 448 });
|
|
48764
48714
|
try {
|
|
48765
|
-
(0,
|
|
48715
|
+
(0, import_node_fs8.writeFileSync)(
|
|
48766
48716
|
pendingPath,
|
|
48767
48717
|
JSON.stringify({
|
|
48768
48718
|
version: 1,
|
|
@@ -48775,10 +48725,10 @@ var DurablePendingRunStarts = class extends Map {
|
|
|
48775
48725
|
}),
|
|
48776
48726
|
{ mode: 384 }
|
|
48777
48727
|
);
|
|
48778
|
-
(0,
|
|
48779
|
-
(0,
|
|
48728
|
+
(0, import_node_fs8.chmodSync)(pendingPath, 384);
|
|
48729
|
+
(0, import_node_fs8.renameSync)(pendingPath, this.path);
|
|
48780
48730
|
} finally {
|
|
48781
|
-
(0,
|
|
48731
|
+
(0, import_node_fs8.rmSync)(pendingPath, { force: true });
|
|
48782
48732
|
}
|
|
48783
48733
|
}
|
|
48784
48734
|
};
|
|
@@ -49022,7 +48972,7 @@ function collectRuntimeMetadata() {
|
|
|
49022
48972
|
metadata.cpuCores = cpuList.length;
|
|
49023
48973
|
}
|
|
49024
48974
|
try {
|
|
49025
|
-
const disk = (0,
|
|
48975
|
+
const disk = (0, import_node_fs8.statfsSync)((0, import_node_os5.homedir)());
|
|
49026
48976
|
metadata.diskFreeBytes = disk.bavail * disk.bsize;
|
|
49027
48977
|
metadata.diskTotalBytes = disk.blocks * disk.bsize;
|
|
49028
48978
|
} catch {
|
|
@@ -49229,12 +49179,12 @@ function getConfigPath() {
|
|
|
49229
49179
|
return boundAgentConfigPath ?? process.env.ALAN_AGENT_CONFIG_PATH ?? resolveAgentConfigPath({ profile: "production" });
|
|
49230
49180
|
}
|
|
49231
49181
|
function getEndpointDefaultsPath() {
|
|
49232
|
-
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");
|
|
49233
49183
|
}
|
|
49234
49184
|
function readConfig() {
|
|
49235
49185
|
const configPath = getConfigPath();
|
|
49236
|
-
if (!(0,
|
|
49237
|
-
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"));
|
|
49238
49188
|
const sanitized = sanitizeAgentConfig(parsed);
|
|
49239
49189
|
if (Object.keys(parsed).some((key) => !Object.hasOwn(sanitized, key))) {
|
|
49240
49190
|
writeConfig(sanitized);
|
|
@@ -49250,27 +49200,27 @@ function readConfigForRegistration() {
|
|
|
49250
49200
|
}
|
|
49251
49201
|
function readEndpointDefaults() {
|
|
49252
49202
|
const endpointsPath = getEndpointDefaultsPath();
|
|
49253
|
-
if (!(0,
|
|
49203
|
+
if (!(0, import_node_fs9.existsSync)(endpointsPath)) return {};
|
|
49254
49204
|
try {
|
|
49255
|
-
return JSON.parse((0,
|
|
49205
|
+
return JSON.parse((0, import_node_fs9.readFileSync)(endpointsPath, "utf8"));
|
|
49256
49206
|
} catch {
|
|
49257
49207
|
return {};
|
|
49258
49208
|
}
|
|
49259
49209
|
}
|
|
49260
49210
|
function writeConfig(config2) {
|
|
49261
49211
|
const configPath = getConfigPath();
|
|
49262
|
-
(0,
|
|
49212
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(configPath), { recursive: true, mode: 448 });
|
|
49263
49213
|
const pendingPath = `${configPath}.pending-${process.pid}-${(0, import_node_crypto5.randomBytes)(6).toString("hex")}`;
|
|
49264
49214
|
try {
|
|
49265
|
-
(0,
|
|
49215
|
+
(0, import_node_fs9.writeFileSync)(
|
|
49266
49216
|
pendingPath,
|
|
49267
49217
|
JSON.stringify(sanitizeAgentConfig(config2), null, 2),
|
|
49268
49218
|
{ mode: 384 }
|
|
49269
49219
|
);
|
|
49270
|
-
(0,
|
|
49271
|
-
(0,
|
|
49220
|
+
(0, import_node_fs9.chmodSync)(pendingPath, 384);
|
|
49221
|
+
(0, import_node_fs9.renameSync)(pendingPath, configPath);
|
|
49272
49222
|
} finally {
|
|
49273
|
-
(0,
|
|
49223
|
+
(0, import_node_fs9.rmSync)(pendingPath, { force: true });
|
|
49274
49224
|
}
|
|
49275
49225
|
}
|
|
49276
49226
|
function maintenanceLeasePath(configPath) {
|
|
@@ -49278,9 +49228,9 @@ function maintenanceLeasePath(configPath) {
|
|
|
49278
49228
|
}
|
|
49279
49229
|
function readLocalDaemonMaintenanceLease(configPath, nowMs = Date.now()) {
|
|
49280
49230
|
const path2 = maintenanceLeasePath(configPath);
|
|
49281
|
-
if (!(0,
|
|
49231
|
+
if (!(0, import_node_fs9.existsSync)(path2)) return null;
|
|
49282
49232
|
try {
|
|
49283
|
-
const lease = JSON.parse((0,
|
|
49233
|
+
const lease = JSON.parse((0, import_node_fs9.readFileSync)(path2, "utf8"));
|
|
49284
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))) {
|
|
49285
49235
|
throw new Error("invalid maintenance lease");
|
|
49286
49236
|
}
|
|
@@ -49297,8 +49247,8 @@ function readLocalDaemonMaintenanceLease(configPath, nowMs = Date.now()) {
|
|
|
49297
49247
|
expiresAtMs: nowMs + 5e3
|
|
49298
49248
|
};
|
|
49299
49249
|
try {
|
|
49300
|
-
(0,
|
|
49301
|
-
(0,
|
|
49250
|
+
(0, import_node_fs9.writeFileSync)(path2, JSON.stringify(fallback), { mode: 384 });
|
|
49251
|
+
(0, import_node_fs9.chmodSync)(path2, 384);
|
|
49302
49252
|
} catch {
|
|
49303
49253
|
}
|
|
49304
49254
|
return fallback;
|
|
@@ -49314,10 +49264,10 @@ function acquireLocalDaemonMaintenanceLease(configPath, reason, ttlMs = 5e3) {
|
|
|
49314
49264
|
expiresAtMs: reason === "credential_cleanup" ? null : Date.now() + Math.max(1e3, Math.min(ttlMs, 6e4))
|
|
49315
49265
|
};
|
|
49316
49266
|
const path2 = maintenanceLeasePath(configPath);
|
|
49317
|
-
(0,
|
|
49267
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(path2), { recursive: true, mode: 448 });
|
|
49318
49268
|
try {
|
|
49319
|
-
(0,
|
|
49320
|
-
(0,
|
|
49269
|
+
(0, import_node_fs9.writeFileSync)(path2, JSON.stringify(lease), { mode: 384, flag: "wx" });
|
|
49270
|
+
(0, import_node_fs9.chmodSync)(path2, 384);
|
|
49321
49271
|
return { acquired: true, lease };
|
|
49322
49272
|
} catch (error61) {
|
|
49323
49273
|
const raced = readLocalDaemonMaintenanceLease(configPath);
|
|
@@ -49333,9 +49283,9 @@ function daemonOwnerLeasePath(configPath) {
|
|
|
49333
49283
|
}
|
|
49334
49284
|
function readLocalDaemonOwnerLease(configPath) {
|
|
49335
49285
|
const path2 = daemonOwnerLeasePath(configPath);
|
|
49336
|
-
if (!(0,
|
|
49286
|
+
if (!(0, import_node_fs9.existsSync)(path2)) return null;
|
|
49337
49287
|
try {
|
|
49338
|
-
const lease = JSON.parse((0,
|
|
49288
|
+
const lease = JSON.parse((0, import_node_fs9.readFileSync)(path2, "utf8"));
|
|
49339
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) {
|
|
49340
49290
|
throw new Error("invalid daemon owner lease");
|
|
49341
49291
|
}
|
|
@@ -49390,10 +49340,10 @@ async function acquireLocalDaemonOwnerLease(input2) {
|
|
|
49390
49340
|
localApiToken: input2.localApiToken
|
|
49391
49341
|
};
|
|
49392
49342
|
const path2 = daemonOwnerLeasePath(input2.configPath);
|
|
49393
|
-
(0,
|
|
49343
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(path2), { recursive: true, mode: 448 });
|
|
49394
49344
|
try {
|
|
49395
|
-
(0,
|
|
49396
|
-
(0,
|
|
49345
|
+
(0, import_node_fs9.writeFileSync)(path2, JSON.stringify(lease), { mode: 384, flag: "wx" });
|
|
49346
|
+
(0, import_node_fs9.chmodSync)(path2, 384);
|
|
49397
49347
|
return { acquired: true, lease };
|
|
49398
49348
|
} catch (error61) {
|
|
49399
49349
|
const raced = readLocalDaemonOwnerLease(input2.configPath);
|
|
@@ -49408,12 +49358,12 @@ function updateLocalDaemonOwnerEndpoint(configPath, lease, localApiPort) {
|
|
|
49408
49358
|
const path2 = daemonOwnerLeasePath(configPath);
|
|
49409
49359
|
const pendingPath = `${path2}.pending-${lease.id}`;
|
|
49410
49360
|
try {
|
|
49411
|
-
(0,
|
|
49412
|
-
(0,
|
|
49413
|
-
(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);
|
|
49414
49364
|
return updated;
|
|
49415
49365
|
} finally {
|
|
49416
|
-
(0,
|
|
49366
|
+
(0, import_node_fs9.rmSync)(pendingPath, { force: true });
|
|
49417
49367
|
}
|
|
49418
49368
|
}
|
|
49419
49369
|
function releaseLocalDaemonOwnerLease(configPath, leaseId) {
|
|
@@ -49422,13 +49372,13 @@ function releaseLocalDaemonOwnerLease(configPath, leaseId) {
|
|
|
49422
49372
|
function releaseOwnedJsonFile(path2, ownerId, ownerField = "id") {
|
|
49423
49373
|
const releasePath = `${path2}.release-${process.pid}-${(0, import_node_crypto5.randomBytes)(6).toString("hex")}`;
|
|
49424
49374
|
try {
|
|
49425
|
-
(0,
|
|
49375
|
+
(0, import_node_fs9.renameSync)(path2, releasePath);
|
|
49426
49376
|
} catch (error61) {
|
|
49427
49377
|
if (error61.code === "ENOENT") return;
|
|
49428
49378
|
throw error61;
|
|
49429
49379
|
}
|
|
49430
49380
|
try {
|
|
49431
|
-
const content = (0,
|
|
49381
|
+
const content = (0, import_node_fs9.readFileSync)(releasePath, "utf8");
|
|
49432
49382
|
let capturedOwnerId = null;
|
|
49433
49383
|
try {
|
|
49434
49384
|
const captured = JSON.parse(content);
|
|
@@ -49437,13 +49387,13 @@ function releaseOwnedJsonFile(path2, ownerId, ownerField = "id") {
|
|
|
49437
49387
|
}
|
|
49438
49388
|
if (capturedOwnerId === ownerId) return;
|
|
49439
49389
|
try {
|
|
49440
|
-
(0,
|
|
49441
|
-
(0,
|
|
49390
|
+
(0, import_node_fs9.writeFileSync)(path2, content, { mode: 384, flag: "wx" });
|
|
49391
|
+
(0, import_node_fs9.chmodSync)(path2, 384);
|
|
49442
49392
|
} catch (error61) {
|
|
49443
49393
|
if (error61.code !== "EEXIST") throw error61;
|
|
49444
49394
|
}
|
|
49445
49395
|
} finally {
|
|
49446
|
-
(0,
|
|
49396
|
+
(0, import_node_fs9.rmSync)(releasePath, { force: true });
|
|
49447
49397
|
}
|
|
49448
49398
|
}
|
|
49449
49399
|
function inspectLocalDaemonRunJournal(configPath) {
|
|
@@ -49453,8 +49403,8 @@ function inspectLocalDaemonRunJournal(configPath) {
|
|
|
49453
49403
|
try {
|
|
49454
49404
|
let activeRunCount = 0;
|
|
49455
49405
|
for (const artifact of [path2, pendingPath]) {
|
|
49456
|
-
if (!(0,
|
|
49457
|
-
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"));
|
|
49458
49408
|
if (parsed.version !== 1 || !Array.isArray(parsed.entries))
|
|
49459
49409
|
throw new Error("invalid journal");
|
|
49460
49410
|
if (artifact === path2) {
|
|
@@ -49473,7 +49423,7 @@ function inspectLocalDaemonRunJournal(configPath) {
|
|
|
49473
49423
|
}).length;
|
|
49474
49424
|
continue;
|
|
49475
49425
|
}
|
|
49476
|
-
const legacyStartedAtMs = (0,
|
|
49426
|
+
const legacyStartedAtMs = (0, import_node_fs9.statSync)(pendingPath).mtimeMs;
|
|
49477
49427
|
activeRunCount += parsed.entries.filter((entry) => {
|
|
49478
49428
|
if (!entry || typeof entry !== "object") throw new Error("invalid pending run entry");
|
|
49479
49429
|
const startedAtMs = entry.startedAtMs;
|
|
@@ -49500,9 +49450,9 @@ function setupTokenHash(setupToken) {
|
|
|
49500
49450
|
function getOrCreateSetupAttemptId(setupToken) {
|
|
49501
49451
|
const intentPath = pendingSetupIntentPath();
|
|
49502
49452
|
const tokenHash = setupTokenHash(setupToken);
|
|
49503
|
-
if ((0,
|
|
49453
|
+
if ((0, import_node_fs9.existsSync)(intentPath)) {
|
|
49504
49454
|
try {
|
|
49505
|
-
const stored = JSON.parse((0,
|
|
49455
|
+
const stored = JSON.parse((0, import_node_fs9.readFileSync)(intentPath, "utf8"));
|
|
49506
49456
|
if (stored.setupTokenHash === tokenHash && typeof stored.registrationAttemptId === "string" && stored.registrationAttemptId.length > 0) {
|
|
49507
49457
|
return stored.registrationAttemptId;
|
|
49508
49458
|
}
|
|
@@ -49510,23 +49460,23 @@ function getOrCreateSetupAttemptId(setupToken) {
|
|
|
49510
49460
|
}
|
|
49511
49461
|
}
|
|
49512
49462
|
const registrationAttemptId = (0, import_node_crypto5.randomUUID)();
|
|
49513
|
-
(0,
|
|
49463
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(intentPath), { recursive: true, mode: 448 });
|
|
49514
49464
|
const writePath = `${intentPath}.pending-${process.pid}-${(0, import_node_crypto5.randomBytes)(6).toString("hex")}`;
|
|
49515
49465
|
try {
|
|
49516
|
-
(0,
|
|
49466
|
+
(0, import_node_fs9.writeFileSync)(
|
|
49517
49467
|
writePath,
|
|
49518
49468
|
JSON.stringify({ setupTokenHash: tokenHash, registrationAttemptId }, null, 2),
|
|
49519
49469
|
{ mode: 384 }
|
|
49520
49470
|
);
|
|
49521
|
-
(0,
|
|
49522
|
-
(0,
|
|
49471
|
+
(0, import_node_fs9.chmodSync)(writePath, 384);
|
|
49472
|
+
(0, import_node_fs9.renameSync)(writePath, intentPath);
|
|
49523
49473
|
} finally {
|
|
49524
|
-
(0,
|
|
49474
|
+
(0, import_node_fs9.rmSync)(writePath, { force: true });
|
|
49525
49475
|
}
|
|
49526
49476
|
return registrationAttemptId;
|
|
49527
49477
|
}
|
|
49528
49478
|
function clearPendingSetupIntent() {
|
|
49529
|
-
(0,
|
|
49479
|
+
(0, import_node_fs9.rmSync)(pendingSetupIntentPath(), { force: true });
|
|
49530
49480
|
}
|
|
49531
49481
|
function pendingDeviceAuthorizationPath() {
|
|
49532
49482
|
return `${getConfigPath()}.device-auth-pending`;
|
|
@@ -49547,8 +49497,8 @@ function parseDeviceAuthorizationOperationContent(content) {
|
|
|
49547
49497
|
}
|
|
49548
49498
|
function restoreCapturedFileUnlessReplaced(path2, content) {
|
|
49549
49499
|
try {
|
|
49550
|
-
(0,
|
|
49551
|
-
(0,
|
|
49500
|
+
(0, import_node_fs9.writeFileSync)(path2, content, { mode: 384, flag: "wx" });
|
|
49501
|
+
(0, import_node_fs9.chmodSync)(path2, 384);
|
|
49552
49502
|
} catch (error61) {
|
|
49553
49503
|
if (error61.code !== "EEXIST") throw error61;
|
|
49554
49504
|
}
|
|
@@ -49556,26 +49506,26 @@ function restoreCapturedFileUnlessReplaced(path2, content) {
|
|
|
49556
49506
|
function quarantineCorruptDeviceAuthorizationOperation(path2) {
|
|
49557
49507
|
const quarantinePath = `${path2}.corrupt-${process.pid}-${(0, import_node_crypto5.randomBytes)(6).toString("hex")}`;
|
|
49558
49508
|
try {
|
|
49559
|
-
(0,
|
|
49509
|
+
(0, import_node_fs9.renameSync)(path2, quarantinePath);
|
|
49560
49510
|
} catch (error61) {
|
|
49561
49511
|
if (error61.code === "ENOENT") return null;
|
|
49562
49512
|
throw error61;
|
|
49563
49513
|
}
|
|
49564
49514
|
try {
|
|
49565
|
-
const capturedContent = (0,
|
|
49515
|
+
const capturedContent = (0, import_node_fs9.readFileSync)(quarantinePath, "utf8");
|
|
49566
49516
|
if (parseDeviceAuthorizationOperationContent(capturedContent)) {
|
|
49567
49517
|
restoreCapturedFileUnlessReplaced(path2, capturedContent);
|
|
49568
49518
|
}
|
|
49569
49519
|
} finally {
|
|
49570
|
-
(0,
|
|
49520
|
+
(0, import_node_fs9.rmSync)(quarantinePath, { force: true });
|
|
49571
49521
|
}
|
|
49572
|
-
if (!(0,
|
|
49573
|
-
return parseDeviceAuthorizationOperationContent((0,
|
|
49522
|
+
if (!(0, import_node_fs9.existsSync)(path2)) return null;
|
|
49523
|
+
return parseDeviceAuthorizationOperationContent((0, import_node_fs9.readFileSync)(path2, "utf8"));
|
|
49574
49524
|
}
|
|
49575
49525
|
function readDeviceAuthorizationOperation() {
|
|
49576
49526
|
const path2 = deviceAuthorizationOperationPath();
|
|
49577
|
-
if (!(0,
|
|
49578
|
-
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"));
|
|
49579
49529
|
const lease = parsed ?? quarantineCorruptDeviceAuthorizationOperation(path2);
|
|
49580
49530
|
if (!lease) return null;
|
|
49581
49531
|
if (lease.expiresAtMs <= Date.now()) {
|
|
@@ -49593,10 +49543,10 @@ function acquireDeviceAuthorizationOperation() {
|
|
|
49593
49543
|
expiresAtMs: Date.now() + 6e4
|
|
49594
49544
|
};
|
|
49595
49545
|
const path2 = deviceAuthorizationOperationPath();
|
|
49596
|
-
(0,
|
|
49546
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(path2), { recursive: true, mode: 448 });
|
|
49597
49547
|
try {
|
|
49598
|
-
(0,
|
|
49599
|
-
(0,
|
|
49548
|
+
(0, import_node_fs9.writeFileSync)(path2, JSON.stringify(lease), { mode: 384, flag: "wx" });
|
|
49549
|
+
(0, import_node_fs9.chmodSync)(path2, 384);
|
|
49600
49550
|
return lease;
|
|
49601
49551
|
} catch (error61) {
|
|
49602
49552
|
if (error61.code === "EEXIST") return null;
|
|
@@ -49611,15 +49561,15 @@ function extendDeviceAuthorizationOperation(operationId, expiresAtMs) {
|
|
|
49611
49561
|
const path2 = deviceAuthorizationOperationPath();
|
|
49612
49562
|
const pendingPath = `${path2}.pending-${process.pid}-${(0, import_node_crypto5.randomBytes)(6).toString("hex")}`;
|
|
49613
49563
|
try {
|
|
49614
|
-
(0,
|
|
49564
|
+
(0, import_node_fs9.writeFileSync)(
|
|
49615
49565
|
pendingPath,
|
|
49616
49566
|
JSON.stringify({ ...current, expiresAtMs: Math.max(expiresAtMs, Date.now() + 6e4) }),
|
|
49617
49567
|
{ mode: 384 }
|
|
49618
49568
|
);
|
|
49619
|
-
(0,
|
|
49620
|
-
(0,
|
|
49569
|
+
(0, import_node_fs9.chmodSync)(pendingPath, 384);
|
|
49570
|
+
(0, import_node_fs9.renameSync)(pendingPath, path2);
|
|
49621
49571
|
} finally {
|
|
49622
|
-
(0,
|
|
49572
|
+
(0, import_node_fs9.rmSync)(pendingPath, { force: true });
|
|
49623
49573
|
}
|
|
49624
49574
|
}
|
|
49625
49575
|
function assertDeviceAuthorizationOperationOwner(operationId) {
|
|
@@ -49630,12 +49580,12 @@ function assertDeviceAuthorizationOperationOwner(operationId) {
|
|
|
49630
49580
|
function clearPendingDeviceAuthorization(operationId) {
|
|
49631
49581
|
const path2 = pendingDeviceAuthorizationPath();
|
|
49632
49582
|
if (!operationId) {
|
|
49633
|
-
(0,
|
|
49583
|
+
(0, import_node_fs9.rmSync)(path2, { force: true });
|
|
49634
49584
|
return;
|
|
49635
49585
|
}
|
|
49636
|
-
if (!(0,
|
|
49586
|
+
if (!(0, import_node_fs9.existsSync)(path2)) return;
|
|
49637
49587
|
try {
|
|
49638
|
-
const pending = JSON.parse((0,
|
|
49588
|
+
const pending = JSON.parse((0, import_node_fs9.readFileSync)(path2, "utf8"));
|
|
49639
49589
|
if (pending.operationId !== operationId) return;
|
|
49640
49590
|
} catch {
|
|
49641
49591
|
return;
|
|
@@ -49644,9 +49594,9 @@ function clearPendingDeviceAuthorization(operationId) {
|
|
|
49644
49594
|
}
|
|
49645
49595
|
function readPendingDeviceAuthorization(apiUrl) {
|
|
49646
49596
|
const path2 = pendingDeviceAuthorizationPath();
|
|
49647
|
-
if (!(0,
|
|
49597
|
+
if (!(0, import_node_fs9.existsSync)(path2)) return null;
|
|
49648
49598
|
try {
|
|
49649
|
-
const pending = JSON.parse((0,
|
|
49599
|
+
const pending = JSON.parse((0, import_node_fs9.readFileSync)(path2, "utf8"));
|
|
49650
49600
|
const expiresAtMs = Date.parse(pending.expiresAt ?? "");
|
|
49651
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()) {
|
|
49652
49602
|
return null;
|
|
@@ -49658,20 +49608,20 @@ function readPendingDeviceAuthorization(apiUrl) {
|
|
|
49658
49608
|
}
|
|
49659
49609
|
function writePendingDeviceAuthorization(pending) {
|
|
49660
49610
|
const path2 = pendingDeviceAuthorizationPath();
|
|
49661
|
-
(0,
|
|
49611
|
+
(0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(path2), { recursive: true, mode: 448 });
|
|
49662
49612
|
const writePath = `${path2}.pending-${process.pid}-${(0, import_node_crypto5.randomBytes)(6).toString("hex")}`;
|
|
49663
49613
|
try {
|
|
49664
|
-
(0,
|
|
49665
|
-
(0,
|
|
49666
|
-
(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);
|
|
49667
49617
|
} finally {
|
|
49668
|
-
(0,
|
|
49618
|
+
(0, import_node_fs9.rmSync)(writePath, { force: true });
|
|
49669
49619
|
}
|
|
49670
49620
|
}
|
|
49671
49621
|
function removeAlanOwnedLocalArtifacts() {
|
|
49672
49622
|
const configPath = getConfigPath();
|
|
49673
|
-
const directory = (0,
|
|
49674
|
-
const configName = (0,
|
|
49623
|
+
const directory = (0, import_node_path10.dirname)(configPath);
|
|
49624
|
+
const configName = (0, import_node_path10.basename)(configPath).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
49675
49625
|
const alanAtomicSidecarPattern = new RegExp(
|
|
49676
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}$`
|
|
49677
49627
|
);
|
|
@@ -49688,19 +49638,26 @@ function removeAlanOwnedLocalArtifacts() {
|
|
|
49688
49638
|
`${configPath}.pending-runs.json.pending`,
|
|
49689
49639
|
maintenanceLeasePath(configPath)
|
|
49690
49640
|
]);
|
|
49691
|
-
if ((0,
|
|
49692
|
-
for (const entry of (0,
|
|
49693
|
-
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));
|
|
49694
49644
|
}
|
|
49695
49645
|
}
|
|
49696
|
-
for (const artifact of artifacts) (0,
|
|
49697
|
-
|
|
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 });
|
|
49698
49655
|
}
|
|
49699
49656
|
|
|
49700
49657
|
// src/provider-model-discovery.ts
|
|
49701
|
-
var
|
|
49658
|
+
var import_node_fs10 = require("fs");
|
|
49702
49659
|
var import_node_os6 = require("os");
|
|
49703
|
-
var
|
|
49660
|
+
var import_node_path11 = require("path");
|
|
49704
49661
|
var MODEL_DISCOVERY_TIMEOUT_MS = 8e3;
|
|
49705
49662
|
var ANTIGRAVITY_MODEL_DISCOVERY_TIMEOUT_MS = 12e3;
|
|
49706
49663
|
var OPENCODE_ZEN_MODEL_IDS = OPENCODE_ZEN_MODELS.map((model) => model.id);
|
|
@@ -49912,7 +49869,7 @@ function filterClaudeDatedModelIds(ids) {
|
|
|
49912
49869
|
}
|
|
49913
49870
|
function resolveExecutableForModelScan(executable) {
|
|
49914
49871
|
try {
|
|
49915
|
-
return (0,
|
|
49872
|
+
return (0, import_node_fs10.realpathSync)(executable);
|
|
49916
49873
|
} catch {
|
|
49917
49874
|
return executable;
|
|
49918
49875
|
}
|
|
@@ -49920,7 +49877,7 @@ function resolveExecutableForModelScan(executable) {
|
|
|
49920
49877
|
function extractClaudeModelIdsFromExecutable(executable) {
|
|
49921
49878
|
try {
|
|
49922
49879
|
const resolved = resolveExecutableForModelScan(executable);
|
|
49923
|
-
const text = (0,
|
|
49880
|
+
const text = (0, import_node_fs10.readFileSync)(resolved).toString("latin1");
|
|
49924
49881
|
const matches = text.match(CLAUDE_MODEL_ID_PATTERN) ?? [];
|
|
49925
49882
|
const unique2 = [
|
|
49926
49883
|
...new Set(matches.map((id) => id.trim()).filter((id) => isValidClaudeModelId(id))),
|
|
@@ -49979,9 +49936,9 @@ function readOpenCodeZenCredential(env) {
|
|
|
49979
49936
|
function readOpenCodeAuthDocument(env) {
|
|
49980
49937
|
const injected = env.OPENCODE_AUTH_CONTENT?.trim();
|
|
49981
49938
|
if (injected) return injected;
|
|
49982
|
-
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");
|
|
49983
49940
|
try {
|
|
49984
|
-
return (0,
|
|
49941
|
+
return (0, import_node_fs10.readFileSync)((0, import_node_path11.join)(dataHome, "opencode", "auth.json"), "utf8");
|
|
49985
49942
|
} catch {
|
|
49986
49943
|
return null;
|
|
49987
49944
|
}
|
|
@@ -50064,11 +50021,11 @@ function applyZenEntitlement(discovery, entitled) {
|
|
|
50064
50021
|
var OPENCODE_CATALOGUE_CACHE_SEGMENTS = ["opencode", "models.json"];
|
|
50065
50022
|
var OPENCODE_CACHE_PROVIDER_KEYS = ["opencode", "opencode-go"];
|
|
50066
50023
|
function readOpenCodeCatalogueCache(env) {
|
|
50067
|
-
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");
|
|
50068
50025
|
let parsed;
|
|
50069
50026
|
try {
|
|
50070
50027
|
parsed = JSON.parse(
|
|
50071
|
-
(0,
|
|
50028
|
+
(0, import_node_fs10.readFileSync)((0, import_node_path11.join)(cacheHome, ...OPENCODE_CATALOGUE_CACHE_SEGMENTS), "utf8")
|
|
50072
50029
|
);
|
|
50073
50030
|
} catch {
|
|
50074
50031
|
return null;
|
|
@@ -54231,11 +54188,11 @@ Object.assign(lookup, {
|
|
|
54231
54188
|
});
|
|
54232
54189
|
|
|
54233
54190
|
// src/binding-switch-git.ts
|
|
54234
|
-
var
|
|
54191
|
+
var import_node_child_process6 = require("child_process");
|
|
54235
54192
|
var import_node_crypto6 = require("crypto");
|
|
54236
|
-
var
|
|
54193
|
+
var import_node_fs11 = require("fs");
|
|
54237
54194
|
var import_node_os7 = require("os");
|
|
54238
|
-
var
|
|
54195
|
+
var import_node_path12 = require("path");
|
|
54239
54196
|
var import_node_url = require("url");
|
|
54240
54197
|
var BINDING_SWITCH_GIT_METHODS = [
|
|
54241
54198
|
"git.status",
|
|
@@ -54260,7 +54217,7 @@ var LOCAL_GIT_TIMEOUT_MS = 1e4;
|
|
|
54260
54217
|
var NETWORK_GIT_TIMEOUT_MS = 3e4;
|
|
54261
54218
|
var MAX_GIT_OUTPUT_BYTES = 10 * 1024 * 1024;
|
|
54262
54219
|
function runGitResult(cwd, args, options = {}) {
|
|
54263
|
-
const result = (0,
|
|
54220
|
+
const result = (0, import_node_child_process6.spawnSync)("git", args, {
|
|
54264
54221
|
cwd,
|
|
54265
54222
|
env: { ...getDaemonCliEnvironment(), ...options.env },
|
|
54266
54223
|
encoding: "utf8",
|
|
@@ -54285,12 +54242,12 @@ function networkGitTimeoutMs() {
|
|
|
54285
54242
|
async function waitForCheckpointTestBarrier() {
|
|
54286
54243
|
const barrierDir = process.env.NODE_ENV === "test" ? process.env.ALAN_TEST_GIT_CHECKPOINT_BARRIER_DIR : void 0;
|
|
54287
54244
|
if (!barrierDir) return;
|
|
54288
|
-
(0,
|
|
54289
|
-
const readyPath = (0,
|
|
54290
|
-
const releasePath = (0,
|
|
54291
|
-
(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");
|
|
54292
54249
|
const deadline = Date.now() + 5e3;
|
|
54293
|
-
while (!(0,
|
|
54250
|
+
while (!(0, import_node_fs11.existsSync)(releasePath)) {
|
|
54294
54251
|
if (Date.now() >= deadline) {
|
|
54295
54252
|
throw new BindingSwitchGitError(
|
|
54296
54253
|
"checkpoint_prepare_timeout",
|
|
@@ -54303,12 +54260,12 @@ async function waitForCheckpointTestBarrier() {
|
|
|
54303
54260
|
async function waitForCheckpointFinalizeTestBarrier() {
|
|
54304
54261
|
const barrierDir = process.env.NODE_ENV === "test" ? process.env.ALAN_TEST_GIT_CHECKPOINT_FINALIZE_BARRIER_DIR : void 0;
|
|
54305
54262
|
if (!barrierDir) return;
|
|
54306
|
-
(0,
|
|
54307
|
-
const readyPath = (0,
|
|
54308
|
-
const releasePath = (0,
|
|
54309
|
-
(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");
|
|
54310
54267
|
const deadline = Date.now() + 5e3;
|
|
54311
|
-
while (!(0,
|
|
54268
|
+
while (!(0, import_node_fs11.existsSync)(releasePath)) {
|
|
54312
54269
|
if (Date.now() >= deadline) {
|
|
54313
54270
|
throw new BindingSwitchGitError(
|
|
54314
54271
|
"checkpoint_finalize_timeout",
|
|
@@ -54320,7 +54277,7 @@ async function waitForCheckpointFinalizeTestBarrier() {
|
|
|
54320
54277
|
}
|
|
54321
54278
|
async function runNetworkGit(cwd, args, code) {
|
|
54322
54279
|
return new Promise((resolvePromise, rejectPromise) => {
|
|
54323
|
-
const child = (0,
|
|
54280
|
+
const child = (0, import_node_child_process6.spawn)("git", args, {
|
|
54324
54281
|
cwd,
|
|
54325
54282
|
env: {
|
|
54326
54283
|
...getDaemonCliEnvironment(),
|
|
@@ -54421,7 +54378,7 @@ function sourceChangedDuringCheckpoint(message) {
|
|
|
54421
54378
|
}
|
|
54422
54379
|
function acquireCheckpointHeadLock(locks) {
|
|
54423
54380
|
try {
|
|
54424
|
-
(0,
|
|
54381
|
+
(0, import_node_fs11.writeFileSync)(locks.headLockPath, "", { flag: "wx" });
|
|
54425
54382
|
locks.headLockHeld = true;
|
|
54426
54383
|
} catch {
|
|
54427
54384
|
throw sourceChangedDuringCheckpoint(
|
|
@@ -54431,7 +54388,7 @@ function acquireCheckpointHeadLock(locks) {
|
|
|
54431
54388
|
}
|
|
54432
54389
|
function releaseCheckpointHeadLock(locks) {
|
|
54433
54390
|
if (!locks.headLockHeld) return;
|
|
54434
|
-
(0,
|
|
54391
|
+
(0, import_node_fs11.rmSync)(locks.headLockPath, { force: true });
|
|
54435
54392
|
locks.headLockHeld = false;
|
|
54436
54393
|
}
|
|
54437
54394
|
function acquireCheckpointRepositoryLocks(repoRoot) {
|
|
@@ -54446,20 +54403,20 @@ function acquireCheckpointRepositoryLocks(repoRoot) {
|
|
|
54446
54403
|
"checkpoint_lock_unavailable"
|
|
54447
54404
|
);
|
|
54448
54405
|
const locks = {
|
|
54449
|
-
headLockPath: (0,
|
|
54406
|
+
headLockPath: (0, import_node_path12.join)(gitDir, "HEAD.lock"),
|
|
54450
54407
|
headLockHeld: false,
|
|
54451
54408
|
indexLockPath: `${indexPath}.lock`,
|
|
54452
54409
|
indexLockHeld: false,
|
|
54453
54410
|
indexPath
|
|
54454
54411
|
};
|
|
54455
54412
|
try {
|
|
54456
|
-
(0,
|
|
54413
|
+
(0, import_node_fs11.writeFileSync)(locks.indexLockPath, "", { flag: "wx" });
|
|
54457
54414
|
locks.indexLockHeld = true;
|
|
54458
54415
|
acquireCheckpointHeadLock(locks);
|
|
54459
54416
|
return locks;
|
|
54460
54417
|
} catch {
|
|
54461
54418
|
if (locks.indexLockHeld) {
|
|
54462
|
-
(0,
|
|
54419
|
+
(0, import_node_fs11.rmSync)(locks.indexLockPath, { force: true });
|
|
54463
54420
|
locks.indexLockHeld = false;
|
|
54464
54421
|
}
|
|
54465
54422
|
throw sourceChangedDuringCheckpoint(
|
|
@@ -54470,7 +54427,7 @@ function acquireCheckpointRepositoryLocks(repoRoot) {
|
|
|
54470
54427
|
function releaseCheckpointRepositoryLocks(locks) {
|
|
54471
54428
|
releaseCheckpointHeadLock(locks);
|
|
54472
54429
|
if (locks.indexLockHeld) {
|
|
54473
|
-
(0,
|
|
54430
|
+
(0, import_node_fs11.rmSync)(locks.indexLockPath, { force: true });
|
|
54474
54431
|
locks.indexLockHeld = false;
|
|
54475
54432
|
}
|
|
54476
54433
|
}
|
|
@@ -54488,8 +54445,8 @@ function assertCheckpointHead(repoRoot, expectedRef, expectedHeadSha) {
|
|
|
54488
54445
|
}
|
|
54489
54446
|
}
|
|
54490
54447
|
function createCheckpointIndexBaseline(repoRoot, checkpointSha) {
|
|
54491
|
-
const tempDir = (0,
|
|
54492
|
-
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");
|
|
54493
54450
|
try {
|
|
54494
54451
|
runGitWithOptions(
|
|
54495
54452
|
repoRoot,
|
|
@@ -54499,14 +54456,14 @@ function createCheckpointIndexBaseline(repoRoot, checkpointSha) {
|
|
|
54499
54456
|
);
|
|
54500
54457
|
return { indexPath, tempDir };
|
|
54501
54458
|
} catch (error61) {
|
|
54502
|
-
(0,
|
|
54459
|
+
(0, import_node_fs11.rmSync)(tempDir, { recursive: true, force: true });
|
|
54503
54460
|
throw error61;
|
|
54504
54461
|
}
|
|
54505
54462
|
}
|
|
54506
54463
|
function installCheckpointIndexBaseline(locks, baselineIndexPath) {
|
|
54507
54464
|
try {
|
|
54508
|
-
(0,
|
|
54509
|
-
(0,
|
|
54465
|
+
(0, import_node_fs11.copyFileSync)(baselineIndexPath, locks.indexLockPath);
|
|
54466
|
+
(0, import_node_fs11.renameSync)(locks.indexLockPath, locks.indexPath);
|
|
54510
54467
|
locks.indexLockHeld = false;
|
|
54511
54468
|
} catch (error61) {
|
|
54512
54469
|
throw new BindingSwitchGitError(
|
|
@@ -54550,7 +54507,7 @@ function commonRequest(params) {
|
|
|
54550
54507
|
return {
|
|
54551
54508
|
switchId: requiredString2(params, "switchId"),
|
|
54552
54509
|
repoKey: requiredString2(params, "repoKey"),
|
|
54553
|
-
repoPath: (0,
|
|
54510
|
+
repoPath: (0, import_node_path12.resolve)(requiredString2(params, "repoPath"))
|
|
54554
54511
|
};
|
|
54555
54512
|
}
|
|
54556
54513
|
function assertCommitSha(sha, key) {
|
|
@@ -54562,7 +54519,7 @@ function assertValidBranch(branch) {
|
|
|
54562
54519
|
if (branch.startsWith("-")) {
|
|
54563
54520
|
throw new BindingSwitchGitError("invalid_git_request", "branch is not a safe Git ref");
|
|
54564
54521
|
}
|
|
54565
|
-
const result = (0,
|
|
54522
|
+
const result = (0, import_node_child_process6.spawnSync)("git", ["check-ref-format", "--branch", branch], {
|
|
54566
54523
|
env: getDaemonCliEnvironment(),
|
|
54567
54524
|
encoding: "utf8"
|
|
54568
54525
|
});
|
|
@@ -54584,8 +54541,8 @@ function canonicalRemoteUrl(repoRoot, value2) {
|
|
|
54584
54541
|
}
|
|
54585
54542
|
const scpStyle = trimmed.match(/^([^/@:\s]+)@([^/:\s]+):(.+)$/);
|
|
54586
54543
|
const urlValue = scpStyle ? `ssh://${scpStyle[1]}@${scpStyle[2]}/${scpStyle[3]}` : trimmed;
|
|
54587
|
-
if ((0,
|
|
54588
|
-
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);
|
|
54589
54546
|
return `file://${canonicalPathWithMissingTail(absolute).replace(/\/+$/, "").replace(/\.git$/, "")}`;
|
|
54590
54547
|
}
|
|
54591
54548
|
let parsed;
|
|
@@ -54652,22 +54609,22 @@ function inspectedRemoteUrl(repoRoot, params) {
|
|
|
54652
54609
|
}
|
|
54653
54610
|
function canonicalPathWithMissingTail(path2) {
|
|
54654
54611
|
const missingSegments = [];
|
|
54655
|
-
let cursor2 = (0,
|
|
54656
|
-
while (!(0,
|
|
54657
|
-
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);
|
|
54658
54615
|
if (parent === cursor2) {
|
|
54659
54616
|
throw new BindingSwitchGitError(
|
|
54660
54617
|
"path_canonicalization_failed",
|
|
54661
54618
|
"The selected path has no existing canonical ancestor"
|
|
54662
54619
|
);
|
|
54663
54620
|
}
|
|
54664
|
-
missingSegments.unshift((0,
|
|
54621
|
+
missingSegments.unshift((0, import_node_path12.basename)(cursor2));
|
|
54665
54622
|
cursor2 = parent;
|
|
54666
54623
|
}
|
|
54667
|
-
return (0,
|
|
54624
|
+
return (0, import_node_path12.join)(import_node_fs11.realpathSync.native(cursor2), ...missingSegments);
|
|
54668
54625
|
}
|
|
54669
54626
|
function resolveRepositoryRoot(requestedPath) {
|
|
54670
|
-
if (!(0,
|
|
54627
|
+
if (!(0, import_node_fs11.existsSync)(requestedPath)) {
|
|
54671
54628
|
throw new BindingSwitchGitError(
|
|
54672
54629
|
"repository_not_found",
|
|
54673
54630
|
`The selected repository path does not exist: ${requestedPath}`
|
|
@@ -54680,7 +54637,7 @@ function resolveRepositoryRoot(requestedPath) {
|
|
|
54680
54637
|
"The selected folder is not inside a Git repository"
|
|
54681
54638
|
);
|
|
54682
54639
|
}
|
|
54683
|
-
return
|
|
54640
|
+
return import_node_fs11.realpathSync.native((0, import_node_path12.resolve)(root.stdout.trim()));
|
|
54684
54641
|
}
|
|
54685
54642
|
function listWorktrees(repoRoot) {
|
|
54686
54643
|
return runGit(repoRoot, ["worktree", "list", "--porcelain"]).split("\n\n").flatMap((entry) => {
|
|
@@ -54699,7 +54656,7 @@ function resolveAuthorizedRepository(params, requireTrustedContext = false) {
|
|
|
54699
54656
|
const { repoPath } = commonRequest(params);
|
|
54700
54657
|
const repoRoot = resolveRepositoryRoot(repoPath);
|
|
54701
54658
|
const expectedRepoRoot = requireTrustedContext ? requiredString2(params, "expectedRepoRoot") : optionalString(params, "expectedRepoRoot");
|
|
54702
|
-
if (expectedRepoRoot && resolveRepositoryRoot((0,
|
|
54659
|
+
if (expectedRepoRoot && resolveRepositoryRoot((0, import_node_path12.resolve)(expectedRepoRoot)) !== repoRoot) {
|
|
54703
54660
|
throw new BindingSwitchGitError(
|
|
54704
54661
|
"repository_path_changed",
|
|
54705
54662
|
"The selected path now resolves to a different Git repository"
|
|
@@ -54707,7 +54664,7 @@ function resolveAuthorizedRepository(params, requireTrustedContext = false) {
|
|
|
54707
54664
|
}
|
|
54708
54665
|
const projectPath = requireTrustedContext ? requiredString2(params, "projectPath") : optionalString(params, "projectPath");
|
|
54709
54666
|
if (!projectPath) return repoRoot;
|
|
54710
|
-
const projectRoot = resolveRepositoryRoot((0,
|
|
54667
|
+
const projectRoot = resolveRepositoryRoot((0, import_node_path12.resolve)(projectPath));
|
|
54711
54668
|
const registrations = listWorktrees(projectRoot);
|
|
54712
54669
|
const registered = registrations.find(({ path: path2 }) => path2 === repoRoot);
|
|
54713
54670
|
if (!registered) {
|
|
@@ -54736,8 +54693,8 @@ function updateLengthPrefixed(hash2, value2) {
|
|
|
54736
54693
|
hash2.update("\0");
|
|
54737
54694
|
}
|
|
54738
54695
|
function proposedTreeSha(repoRoot, headSha) {
|
|
54739
|
-
const tempDir = (0,
|
|
54740
|
-
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");
|
|
54741
54698
|
const options = { env: { GIT_INDEX_FILE: indexPath } };
|
|
54742
54699
|
try {
|
|
54743
54700
|
if (headSha) {
|
|
@@ -54750,7 +54707,7 @@ function proposedTreeSha(repoRoot, headSha) {
|
|
|
54750
54707
|
assertCommitSha(treeSha, "proposedTreeSha");
|
|
54751
54708
|
return treeSha;
|
|
54752
54709
|
} finally {
|
|
54753
|
-
(0,
|
|
54710
|
+
(0, import_node_fs11.rmSync)(tempDir, { recursive: true, force: true });
|
|
54754
54711
|
}
|
|
54755
54712
|
}
|
|
54756
54713
|
function statusFingerprint(repoRoot, porcelain, proposedTree) {
|
|
@@ -54886,7 +54843,7 @@ async function checkpoint(params) {
|
|
|
54886
54843
|
return { repoRoot, sha: status.headSha, replayed: true };
|
|
54887
54844
|
} finally {
|
|
54888
54845
|
if (locks2) releaseCheckpointRepositoryLocks(locks2);
|
|
54889
|
-
(0,
|
|
54846
|
+
(0, import_node_fs11.rmSync)(baseline2.tempDir, { recursive: true, force: true });
|
|
54890
54847
|
}
|
|
54891
54848
|
}
|
|
54892
54849
|
assertSourcePreconditions(status, expectedHeadSha, expectedStatusFingerprint, expectedBranch);
|
|
@@ -54994,7 +54951,7 @@ Alan-Repository-Id: ${repoKey}`;
|
|
|
54994
54951
|
runGitResult(repoRoot, ["update-ref", expectedRef, expectedHeadSha, sha]);
|
|
54995
54952
|
}
|
|
54996
54953
|
if (locks) releaseCheckpointRepositoryLocks(locks);
|
|
54997
|
-
(0,
|
|
54954
|
+
(0, import_node_fs11.rmSync)(baseline.tempDir, { recursive: true, force: true });
|
|
54998
54955
|
}
|
|
54999
54956
|
}
|
|
55000
54957
|
function resolveRemoteBranch(repoRoot, params) {
|
|
@@ -55232,10 +55189,10 @@ var import_node_fs15 = require("fs");
|
|
|
55232
55189
|
var import_node_path16 = require("path");
|
|
55233
55190
|
|
|
55234
55191
|
// src/cli-ensure-install.ts
|
|
55235
|
-
var
|
|
55236
|
-
var
|
|
55192
|
+
var import_node_child_process7 = require("child_process");
|
|
55193
|
+
var import_node_fs12 = require("fs");
|
|
55237
55194
|
var import_node_os8 = require("os");
|
|
55238
|
-
var
|
|
55195
|
+
var import_node_path13 = require("path");
|
|
55239
55196
|
var CLI_RUNTIME_VERSIONS_ENV = "ALAN_CLI_RUNTIME_VERSIONS";
|
|
55240
55197
|
var installOutcomes = /* @__PURE__ */ new Map();
|
|
55241
55198
|
function canInstallProviderCli(backendKind) {
|
|
@@ -55252,14 +55209,14 @@ function currentRuntimePlatform() {
|
|
|
55252
55209
|
}
|
|
55253
55210
|
function resolveWindowsNpmInvocation(env, npmArgs) {
|
|
55254
55211
|
const searchPath = env.PATH ?? env.Path ?? "";
|
|
55255
|
-
for (const rawDirectory of searchPath.split(
|
|
55212
|
+
for (const rawDirectory of searchPath.split(import_node_path13.delimiter)) {
|
|
55256
55213
|
const directory = rawDirectory.trim().replace(/^"|"$/g, "");
|
|
55257
55214
|
if (!directory) continue;
|
|
55258
|
-
const executable = (0,
|
|
55259
|
-
if ((0,
|
|
55260
|
-
const commandShim = (0,
|
|
55261
|
-
const cliScript = (0,
|
|
55262
|
-
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)) {
|
|
55263
55220
|
return { command: process.execPath, args: [cliScript, ...npmArgs] };
|
|
55264
55221
|
}
|
|
55265
55222
|
}
|
|
@@ -55281,7 +55238,7 @@ function runNpmInstall(installSpec, env, timeoutMs) {
|
|
|
55281
55238
|
});
|
|
55282
55239
|
return;
|
|
55283
55240
|
}
|
|
55284
|
-
child = (0,
|
|
55241
|
+
child = (0, import_node_child_process7.spawn)(invocation.command, invocation.args, {
|
|
55285
55242
|
env,
|
|
55286
55243
|
windowsHide: isWin ? true : void 0,
|
|
55287
55244
|
timeout: timeoutMs,
|
|
@@ -55364,25 +55321,25 @@ var import_node_os10 = require("os");
|
|
|
55364
55321
|
|
|
55365
55322
|
// src/antigravity-api-key-config.ts
|
|
55366
55323
|
var import_node_crypto7 = require("crypto");
|
|
55367
|
-
var
|
|
55324
|
+
var import_node_fs13 = require("fs");
|
|
55368
55325
|
var import_node_os9 = require("os");
|
|
55369
|
-
var
|
|
55326
|
+
var import_node_path14 = require("path");
|
|
55370
55327
|
var CONFIG_LOCK_STALE_MS = 3e4;
|
|
55371
55328
|
var CONFIG_LOCK_WAIT_MS = 2e3;
|
|
55372
55329
|
var CONFIG_LOCK_POLL_MS = 20;
|
|
55373
55330
|
async function waitForConfigLock(lockPath) {
|
|
55374
|
-
(0,
|
|
55331
|
+
(0, import_node_fs13.mkdirSync)((0, import_node_path14.dirname)(lockPath), { recursive: true });
|
|
55375
55332
|
const startedAt = Date.now();
|
|
55376
55333
|
while (true) {
|
|
55377
55334
|
try {
|
|
55378
|
-
(0,
|
|
55379
|
-
return () => (0,
|
|
55335
|
+
(0, import_node_fs13.mkdirSync)(lockPath);
|
|
55336
|
+
return () => (0, import_node_fs13.rmSync)(lockPath, { recursive: true, force: true });
|
|
55380
55337
|
} catch (error61) {
|
|
55381
55338
|
const code = error61 && typeof error61 === "object" && "code" in error61 ? error61.code : void 0;
|
|
55382
55339
|
if (code !== "EEXIST") throw error61;
|
|
55383
55340
|
try {
|
|
55384
|
-
if (Date.now() - (0,
|
|
55385
|
-
(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 });
|
|
55386
55343
|
continue;
|
|
55387
55344
|
}
|
|
55388
55345
|
} catch {
|
|
@@ -55405,29 +55362,29 @@ function parseJsonObject2(path2, content) {
|
|
|
55405
55362
|
}
|
|
55406
55363
|
const hash2 = (0, import_node_crypto7.createHash)("sha256").update(content).digest("hex").slice(0, 12);
|
|
55407
55364
|
const backupPath = `${path2}.alan-backup-${hash2}`;
|
|
55408
|
-
if (!(0,
|
|
55365
|
+
if (!(0, import_node_fs13.existsSync)(backupPath)) (0, import_node_fs13.copyFileSync)(path2, backupPath);
|
|
55409
55366
|
throw new Error(
|
|
55410
55367
|
`Existing config is malformed; no changes were applied. Review the backup at ${backupPath}`
|
|
55411
55368
|
);
|
|
55412
55369
|
}
|
|
55413
55370
|
async function configureAntigravityApiKeyMode(home = (0, import_node_os9.homedir)()) {
|
|
55414
|
-
const path2 = (0,
|
|
55371
|
+
const path2 = (0, import_node_path14.join)(home, ".gemini", "antigravity-cli", "settings.json");
|
|
55415
55372
|
const releaseLock = await waitForConfigLock(`${path2}.alan-lock`);
|
|
55416
55373
|
try {
|
|
55417
|
-
const existing = (0,
|
|
55374
|
+
const existing = (0, import_node_fs13.existsSync)(path2) ? (0, import_node_fs13.readFileSync)(path2, "utf8") : "";
|
|
55418
55375
|
const settings = existing.trim() ? parseJsonObject2(path2, existing) : {};
|
|
55419
55376
|
if (settings.modelProvider === "gemini") return false;
|
|
55420
55377
|
settings.modelProvider = "gemini";
|
|
55421
55378
|
const pending = `${path2}.alan-pending-${process.pid}-${(0, import_node_crypto7.randomBytes)(6).toString("hex")}`;
|
|
55422
55379
|
try {
|
|
55423
|
-
(0,
|
|
55380
|
+
(0, import_node_fs13.writeFileSync)(pending, JSON.stringify(settings), {
|
|
55424
55381
|
encoding: "utf8",
|
|
55425
55382
|
mode: 384,
|
|
55426
55383
|
flag: "wx"
|
|
55427
55384
|
});
|
|
55428
|
-
(0,
|
|
55385
|
+
(0, import_node_fs13.renameSync)(pending, path2);
|
|
55429
55386
|
} finally {
|
|
55430
|
-
(0,
|
|
55387
|
+
(0, import_node_fs13.rmSync)(pending, { force: true });
|
|
55431
55388
|
}
|
|
55432
55389
|
return true;
|
|
55433
55390
|
} finally {
|
|
@@ -56267,6 +56224,75 @@ ${input2.userRequest}
|
|
|
56267
56224
|
</user-request>` : instruction;
|
|
56268
56225
|
}
|
|
56269
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
|
+
|
|
56270
56296
|
// src/daemon-execute.ts
|
|
56271
56297
|
async function handleAgentExecute(ctx, payload) {
|
|
56272
56298
|
const {
|
|
@@ -64869,6 +64895,9 @@ var McpSyncService = class {
|
|
|
64869
64895
|
cleanup(previousServers = []) {
|
|
64870
64896
|
removeMcpFromAllClis(previousServers);
|
|
64871
64897
|
}
|
|
64898
|
+
uninstall(apiUrl) {
|
|
64899
|
+
this.cleanup(toManagedMcpServers(buildAlanMcpServers(apiUrl)));
|
|
64900
|
+
}
|
|
64872
64901
|
};
|
|
64873
64902
|
|
|
64874
64903
|
// src/native-hook-config.ts
|
|
@@ -65503,13 +65532,15 @@ function systemdArg(value2) {
|
|
|
65503
65532
|
function powershellLiteral(value2) {
|
|
65504
65533
|
return `'${value2.replaceAll("'", "''")}'`;
|
|
65505
65534
|
}
|
|
65506
|
-
function powershellCommand(script, tolerateFailure = false) {
|
|
65535
|
+
function powershellCommand(script, tolerateFailure = false, commandTimeoutMs) {
|
|
65507
65536
|
return {
|
|
65508
65537
|
command: "powershell.exe",
|
|
65509
65538
|
args: ["-NoProfile", "-NonInteractive", "-Command", script],
|
|
65510
|
-
tolerateFailure
|
|
65539
|
+
tolerateFailure,
|
|
65540
|
+
commandTimeoutMs
|
|
65511
65541
|
};
|
|
65512
65542
|
}
|
|
65543
|
+
var WINDOWS_STATUS_COMMAND_TIMEOUT_MS = 2e4;
|
|
65513
65544
|
function windowsCommandLineArgument(value2) {
|
|
65514
65545
|
if (value2 && !/[\s"]/u.test(value2)) return value2;
|
|
65515
65546
|
const escaped = value2.replace(/(\\*)"/gu, (_match, slashes) => `${slashes}${slashes}\\"`).replace(/\\+$/u, (slashes) => `${slashes}${slashes}`);
|
|
@@ -65890,8 +65921,8 @@ WantedBy=default.target
|
|
|
65890
65921
|
],
|
|
65891
65922
|
forceStopCommands: [],
|
|
65892
65923
|
uninstallCommands: [powershellCommand(uninstallScript)],
|
|
65893
|
-
statusCommand: powershellCommand(statusScript, true),
|
|
65894
|
-
isActiveCommand: powershellCommand(statusScript, true),
|
|
65924
|
+
statusCommand: powershellCommand(statusScript, true, WINDOWS_STATUS_COMMAND_TIMEOUT_MS),
|
|
65925
|
+
isActiveCommand: powershellCommand(statusScript, true, WINDOWS_STATUS_COMMAND_TIMEOUT_MS),
|
|
65895
65926
|
definitionMarker
|
|
65896
65927
|
};
|
|
65897
65928
|
}
|
|
@@ -66116,9 +66147,11 @@ function createHostContext(options = {}) {
|
|
|
66116
66147
|
const run = async (command) => {
|
|
66117
66148
|
const remainingMs = options.deadlineMs === void 0 ? 15e3 : options.deadlineMs - nowMs();
|
|
66118
66149
|
if (remainingMs <= 0) throw new Error("Windows service setup deadline expired");
|
|
66150
|
+
const configuredTimeoutMs = command.commandTimeoutMs ?? options.commandTimeoutMs ?? 1e4;
|
|
66151
|
+
const effectiveTimeoutMs = options.deadlineMs === void 0 ? configuredTimeoutMs : Math.min(configuredTimeoutMs, remainingMs);
|
|
66119
66152
|
const result = options.runCommand ? await options.runCommand(command) : await runServiceCommand(command, {
|
|
66120
66153
|
signal: options.signal,
|
|
66121
|
-
commandTimeoutMs:
|
|
66154
|
+
commandTimeoutMs: effectiveTimeoutMs
|
|
66122
66155
|
});
|
|
66123
66156
|
if (options.deadlineMs !== void 0 && nowMs() >= options.deadlineMs) {
|
|
66124
66157
|
throw new Error("Windows service setup deadline expired");
|
|
@@ -66151,9 +66184,26 @@ function createHostContext(options = {}) {
|
|
|
66151
66184
|
releaseMaintenance: options.releaseMaintenance ?? releaseLocalDaemonMaintenanceLease
|
|
66152
66185
|
};
|
|
66153
66186
|
}
|
|
66187
|
+
function isTransientServiceCommandError(error61) {
|
|
66188
|
+
const cause = error61 instanceof Error ? error61.cause : void 0;
|
|
66189
|
+
return Boolean(cause?.killed) || cause?.name === "AbortError";
|
|
66190
|
+
}
|
|
66154
66191
|
async function inspectDaemonService(options = {}) {
|
|
66155
66192
|
const { plan, run, nowMs } = createHostContext(options);
|
|
66156
|
-
|
|
66193
|
+
let result;
|
|
66194
|
+
try {
|
|
66195
|
+
result = await run(plan.isActiveCommand);
|
|
66196
|
+
} catch (error61) {
|
|
66197
|
+
if (plan.platform === "win32" && isTransientServiceCommandError(error61)) {
|
|
66198
|
+
return {
|
|
66199
|
+
state: "unknown",
|
|
66200
|
+
platform: plan.platform,
|
|
66201
|
+
detail: error61 instanceof Error ? error61.message : String(error61),
|
|
66202
|
+
observedAtMs: nowMs()
|
|
66203
|
+
};
|
|
66204
|
+
}
|
|
66205
|
+
throw error61;
|
|
66206
|
+
}
|
|
66157
66207
|
let state;
|
|
66158
66208
|
if (plan.platform === "win32") {
|
|
66159
66209
|
try {
|
|
@@ -66187,7 +66237,15 @@ async function ensureDaemonServiceDefinition(options = {}) {
|
|
|
66187
66237
|
}
|
|
66188
66238
|
} else if (plan.platform === "win32") {
|
|
66189
66239
|
ensureLogDir();
|
|
66190
|
-
|
|
66240
|
+
let result;
|
|
66241
|
+
try {
|
|
66242
|
+
result = await run(plan.statusCommand);
|
|
66243
|
+
} catch (error61) {
|
|
66244
|
+
if (!isTransientServiceCommandError(error61)) throw error61;
|
|
66245
|
+
}
|
|
66246
|
+
if (!result) {
|
|
66247
|
+
return { changed: false, updatePending: false };
|
|
66248
|
+
}
|
|
66191
66249
|
const tasks = parseWindowsTaskInspection(result);
|
|
66192
66250
|
assertWindowsTaskOwnership(tasks);
|
|
66193
66251
|
if (tasks.currentPresent && tasks.currentState === "unknown" || tasks.legacyPresent && tasks.legacyState === "unknown") {
|
|
@@ -66500,7 +66558,9 @@ async function runInstallCommand(commandArgs, currentPlatform = process.platform
|
|
|
66500
66558
|
if (configurationMode === "login") await loginWithDeviceCode(commandArgs);
|
|
66501
66559
|
await installDaemonService(commandArgs);
|
|
66502
66560
|
}
|
|
66503
|
-
|
|
66561
|
+
if (commandArgs.includes("--with-integrations")) {
|
|
66562
|
+
runMcpIntegrationCommand(["reconcile", ...commandArgs]);
|
|
66563
|
+
}
|
|
66504
66564
|
}
|
|
66505
66565
|
|
|
66506
66566
|
// src/lifecycle-logger.ts
|