@alfe.ai/gateway 0.0.36 → 0.0.38
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/health.js +96 -9
- package/package.json +1 -1
package/dist/health.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
|
|
4
4
|
import { execFile, execSync, spawn } from "node:child_process";
|
|
5
5
|
import { promisify } from "node:util";
|
|
6
|
-
import { join } from "node:path";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import pino from "pino";
|
|
9
9
|
import { chmodSync, existsSync, readFileSync, unlinkSync } from "node:fs";
|
|
@@ -83,6 +83,11 @@ const ID_PREFIXES = {
|
|
|
83
83
|
knowledgeTriple: "kgt",
|
|
84
84
|
accessCode: "acc",
|
|
85
85
|
pendingInject: "pij",
|
|
86
|
+
identity: "idn",
|
|
87
|
+
identityNote: "ino",
|
|
88
|
+
identityTag: "itg",
|
|
89
|
+
identityAlias: "ial",
|
|
90
|
+
attachment: "att",
|
|
86
91
|
run: "run",
|
|
87
92
|
request: "req",
|
|
88
93
|
connection: "conn",
|
|
@@ -519,6 +524,15 @@ var IntegrationsService = class {
|
|
|
519
524
|
disconnectGoogle(agentId) {
|
|
520
525
|
return this.client.request(`/google/agents/${encodeURIComponent(agentId)}/account`, { method: "DELETE" });
|
|
521
526
|
}
|
|
527
|
+
getAtlassianSites(agentId) {
|
|
528
|
+
return this.client.request(`/atlassian/agents/${encodeURIComponent(agentId)}/sites`);
|
|
529
|
+
}
|
|
530
|
+
selectAtlassianSite(agentId, cloudId) {
|
|
531
|
+
return this.client.request(`/atlassian/agents/${encodeURIComponent(agentId)}/sites`, {
|
|
532
|
+
method: "PUT",
|
|
533
|
+
body: JSON.stringify({ cloudId })
|
|
534
|
+
});
|
|
535
|
+
}
|
|
522
536
|
listSlackChannels(agentId) {
|
|
523
537
|
return this.client.request(`/slack/agents/${encodeURIComponent(agentId)}/channels`);
|
|
524
538
|
}
|
|
@@ -3526,6 +3540,46 @@ enumValues({
|
|
|
3526
3540
|
Error: "error"
|
|
3527
3541
|
});
|
|
3528
3542
|
//#endregion
|
|
3543
|
+
//#region ../../packages-internal/types/dist/notification-events.js
|
|
3544
|
+
const NotificationCategory = {
|
|
3545
|
+
Billing: "billing",
|
|
3546
|
+
Agents: "agents",
|
|
3547
|
+
Team: "team",
|
|
3548
|
+
Integrations: "integrations",
|
|
3549
|
+
System: "system"
|
|
3550
|
+
};
|
|
3551
|
+
const NotificationType = {
|
|
3552
|
+
PaymentSucceeded: "payment.succeeded",
|
|
3553
|
+
PaymentFailed: "payment.failed",
|
|
3554
|
+
TopUpCompleted: "top-up.completed",
|
|
3555
|
+
AutoRechargeCompleted: "auto-recharge.completed",
|
|
3556
|
+
AutoRechargeFailed: "auto-recharge.failed",
|
|
3557
|
+
SubscriptionCreated: "subscription.created",
|
|
3558
|
+
SubscriptionCancelled: "subscription.cancelled",
|
|
3559
|
+
SubscriptionPastDue: "subscription.past_due",
|
|
3560
|
+
BalanceThresholdWarning: "balance.threshold.warning",
|
|
3561
|
+
AgentCreated: "agent.created",
|
|
3562
|
+
AgentProvisionFailed: "agent.provision.failed",
|
|
3563
|
+
AgentBillingSuspended: "agent.billing.suspended",
|
|
3564
|
+
AgentDisconnectedExtended: "agent.disconnected.extended",
|
|
3565
|
+
InviteCreated: "onboarding.invite.created",
|
|
3566
|
+
OrgClaimed: "onboarding.org.claimed",
|
|
3567
|
+
TeamMemberAdded: "team.member.added",
|
|
3568
|
+
ProjectMemberAdded: "project.member.added",
|
|
3569
|
+
IntegrationInstalled: "integration.installed",
|
|
3570
|
+
IntegrationRemoved: "integration.removed"
|
|
3571
|
+
};
|
|
3572
|
+
const NotificationChannel = {
|
|
3573
|
+
Email: "email",
|
|
3574
|
+
Push: "push",
|
|
3575
|
+
Sms: "sms"
|
|
3576
|
+
};
|
|
3577
|
+
const RecipientStrategy = {
|
|
3578
|
+
TenantAdmins: "tenant_admins",
|
|
3579
|
+
SpecificUser: "specific_user"
|
|
3580
|
+
};
|
|
3581
|
+
NotificationType.PaymentSucceeded, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.PaymentFailed, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationChannel.Sms, NotificationType.TopUpCompleted, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.AutoRechargeCompleted, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationType.AutoRechargeFailed, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationChannel.Sms, NotificationType.SubscriptionCreated, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationType.SubscriptionCancelled, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.SubscriptionPastDue, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationChannel.Sms, NotificationType.BalanceThresholdWarning, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.AgentCreated, NotificationCategory.Agents, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.AgentProvisionFailed, NotificationCategory.Agents, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.AgentBillingSuspended, NotificationCategory.Agents, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.AgentDisconnectedExtended, NotificationCategory.Agents, RecipientStrategy.TenantAdmins, NotificationChannel.Push, NotificationType.InviteCreated, NotificationCategory.System, RecipientStrategy.SpecificUser, NotificationChannel.Email, NotificationType.OrgClaimed, NotificationCategory.System, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.TeamMemberAdded, NotificationCategory.Team, RecipientStrategy.SpecificUser, NotificationChannel.Email, NotificationChannel.Push, NotificationType.ProjectMemberAdded, NotificationCategory.Team, RecipientStrategy.SpecificUser, NotificationChannel.Email, NotificationChannel.Push, NotificationType.IntegrationInstalled, NotificationCategory.Integrations, RecipientStrategy.TenantAdmins, NotificationChannel.Push, NotificationType.IntegrationRemoved, NotificationCategory.Integrations, RecipientStrategy.TenantAdmins, NotificationChannel.Push;
|
|
3582
|
+
//#endregion
|
|
3529
3583
|
//#region src/config.ts
|
|
3530
3584
|
/**
|
|
3531
3585
|
* Daemon configuration — reads ~/.alfe/config.toml and resolves agent identity.
|
|
@@ -4896,9 +4950,25 @@ function getAlfeBinPath() {
|
|
|
4896
4950
|
}
|
|
4897
4951
|
}
|
|
4898
4952
|
/**
|
|
4953
|
+
* Build the PATH for the launchd plist, ensuring the directory containing the
|
|
4954
|
+
* resolved alfe binary is included (e.g. /opt/homebrew/bin on Apple Silicon).
|
|
4955
|
+
*/
|
|
4956
|
+
function buildLaunchdPath(alfeBin) {
|
|
4957
|
+
const basePaths = [
|
|
4958
|
+
"/usr/local/bin",
|
|
4959
|
+
"/usr/bin",
|
|
4960
|
+
"/bin",
|
|
4961
|
+
join(homedir(), ".local", "bin")
|
|
4962
|
+
];
|
|
4963
|
+
const binDir = dirname(alfeBin);
|
|
4964
|
+
if (binDir && !basePaths.includes(binDir)) basePaths.unshift(binDir);
|
|
4965
|
+
return basePaths.join(":");
|
|
4966
|
+
}
|
|
4967
|
+
/**
|
|
4899
4968
|
* Generate a launchd plist for macOS.
|
|
4900
4969
|
*/
|
|
4901
4970
|
function generateLaunchdPlist() {
|
|
4971
|
+
const alfeBin = getAlfeBinPath();
|
|
4902
4972
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
4903
4973
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
4904
4974
|
<plist version="1.0">
|
|
@@ -4907,7 +4977,7 @@ function generateLaunchdPlist() {
|
|
|
4907
4977
|
<string>${LAUNCHD_LABEL}</string>
|
|
4908
4978
|
<key>ProgramArguments</key>
|
|
4909
4979
|
<array>
|
|
4910
|
-
<string>${
|
|
4980
|
+
<string>${alfeBin}</string>
|
|
4911
4981
|
<string>gateway</string>
|
|
4912
4982
|
<string>daemon</string>
|
|
4913
4983
|
</array>
|
|
@@ -4926,7 +4996,7 @@ function generateLaunchdPlist() {
|
|
|
4926
4996
|
<key>NODE_ENV</key>
|
|
4927
4997
|
<string>production</string>
|
|
4928
4998
|
<key>PATH</key>
|
|
4929
|
-
<string
|
|
4999
|
+
<string>${buildLaunchdPath(alfeBin)}</string>
|
|
4930
5000
|
</dict>
|
|
4931
5001
|
</dict>
|
|
4932
5002
|
</plist>`;
|
|
@@ -4977,20 +5047,38 @@ async function uninstallService() {
|
|
|
4977
5047
|
if (platform === "linux") return uninstallSystemd();
|
|
4978
5048
|
throw new Error(`Unsupported platform: ${platform}`);
|
|
4979
5049
|
}
|
|
5050
|
+
function getLaunchdUid() {
|
|
5051
|
+
return execSync("id -u", { encoding: "utf-8" }).trim();
|
|
5052
|
+
}
|
|
4980
5053
|
async function installLaunchd() {
|
|
4981
5054
|
const plistPath = getLaunchdPlistPath();
|
|
4982
|
-
|
|
5055
|
+
const dir = join(homedir(), "Library", "LaunchAgents");
|
|
5056
|
+
const logsDir = join(homedir(), ".alfe", "logs");
|
|
5057
|
+
await mkdir(dir, { recursive: true });
|
|
5058
|
+
await mkdir(logsDir, { recursive: true });
|
|
4983
5059
|
await writeFile(plistPath, generateLaunchdPlist(), "utf-8");
|
|
4984
5060
|
logger$1.info({ path: plistPath }, "Wrote launchd plist");
|
|
5061
|
+
const uid = getLaunchdUid();
|
|
4985
5062
|
try {
|
|
4986
|
-
execSync(`launchctl
|
|
5063
|
+
execSync(`launchctl bootout gui/${uid}/${LAUNCHD_LABEL}`, { stdio: "pipe" });
|
|
4987
5064
|
} catch {}
|
|
5065
|
+
try {
|
|
5066
|
+
execSync(`launchctl bootstrap gui/${uid} ${plistPath}`, { stdio: "pipe" });
|
|
5067
|
+
} catch (err) {
|
|
5068
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
5069
|
+
logger$1.error({
|
|
5070
|
+
err: msg,
|
|
5071
|
+
plistPath
|
|
5072
|
+
}, "launchctl bootstrap failed");
|
|
5073
|
+
return `Installed plist at ${plistPath}, but failed to bootstrap service: ${msg}`;
|
|
5074
|
+
}
|
|
4988
5075
|
return `Installed: ${plistPath}\nService will start on boot and restart on crash.`;
|
|
4989
5076
|
}
|
|
4990
5077
|
async function uninstallLaunchd() {
|
|
4991
5078
|
const plistPath = getLaunchdPlistPath();
|
|
5079
|
+
const uid = getLaunchdUid();
|
|
4992
5080
|
try {
|
|
4993
|
-
execSync(`launchctl
|
|
5081
|
+
execSync(`launchctl bootout gui/${uid}/${LAUNCHD_LABEL}`, { stdio: "pipe" });
|
|
4994
5082
|
} catch {}
|
|
4995
5083
|
try {
|
|
4996
5084
|
await unlink(plistPath);
|
|
@@ -5036,9 +5124,8 @@ async function uninstallSystemd() {
|
|
|
5036
5124
|
function startService() {
|
|
5037
5125
|
const platform = process.platform;
|
|
5038
5126
|
if (platform === "darwin") {
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
logger$1.info({ path: plistPath }, "Started launchd service");
|
|
5127
|
+
execSync(`launchctl kickstart -k gui/${getLaunchdUid()}/${LAUNCHD_LABEL}`, { stdio: "pipe" });
|
|
5128
|
+
logger$1.info("Started launchd service");
|
|
5042
5129
|
return;
|
|
5043
5130
|
}
|
|
5044
5131
|
if (platform === "linux") {
|