@alfe.ai/gateway 0.0.33 → 0.0.35
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 +68 -29
- package/package.json +2 -2
package/dist/health.js
CHANGED
|
@@ -515,23 +515,8 @@ var IntegrationsService = class {
|
|
|
515
515
|
getMobileNumber(agentId) {
|
|
516
516
|
return this.client.request(`/mobile/numbers?agentId=${encodeURIComponent(agentId)}`);
|
|
517
517
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
method: "POST",
|
|
521
|
-
body: JSON.stringify({
|
|
522
|
-
agentId,
|
|
523
|
-
meetingUrl,
|
|
524
|
-
botName
|
|
525
|
-
})
|
|
526
|
-
});
|
|
527
|
-
return this.client.request("/integrations/recall/join", {
|
|
528
|
-
method: "POST",
|
|
529
|
-
body: JSON.stringify({
|
|
530
|
-
agentId,
|
|
531
|
-
meetingUrl,
|
|
532
|
-
botName
|
|
533
|
-
})
|
|
534
|
-
});
|
|
518
|
+
disconnectGoogle(agentId) {
|
|
519
|
+
return this.client.request(`/google/agents/${encodeURIComponent(agentId)}/account`, { method: "DELETE" });
|
|
535
520
|
}
|
|
536
521
|
listSlackChannels(agentId) {
|
|
537
522
|
return this.client.request(`/slack/agents/${encodeURIComponent(agentId)}/channels`);
|
|
@@ -4009,6 +3994,33 @@ var ReconciliationEngine = class {
|
|
|
4009
3994
|
});
|
|
4010
3995
|
return;
|
|
4011
3996
|
}
|
|
3997
|
+
if (!await this.manager.isInstallIntact(id)) {
|
|
3998
|
+
log$2.info(`Auto-reinstalling ${id} — install directory is corrupted or missing`);
|
|
3999
|
+
try {
|
|
4000
|
+
if ((await this.manager.reinstall(id, desired.version, desired.config)).configApplied) report.configApplied = true;
|
|
4001
|
+
report.installed.push(id);
|
|
4002
|
+
report.activated.push(id);
|
|
4003
|
+
report.results.push({
|
|
4004
|
+
integrationId: id,
|
|
4005
|
+
action: "installed",
|
|
4006
|
+
actualStatus: "active"
|
|
4007
|
+
});
|
|
4008
|
+
} catch (reinstallErr) {
|
|
4009
|
+
const reinstallMsg = reinstallErr instanceof Error ? reinstallErr.message : String(reinstallErr);
|
|
4010
|
+
log$2.error({ err: reinstallErr }, `Auto-reinstall failed for ${id}`);
|
|
4011
|
+
report.errors.push({
|
|
4012
|
+
integrationId: id,
|
|
4013
|
+
error: reinstallMsg
|
|
4014
|
+
});
|
|
4015
|
+
report.results.push({
|
|
4016
|
+
integrationId: id,
|
|
4017
|
+
action: "error",
|
|
4018
|
+
actualStatus: "error",
|
|
4019
|
+
errorMessage: reinstallMsg
|
|
4020
|
+
});
|
|
4021
|
+
}
|
|
4022
|
+
return;
|
|
4023
|
+
}
|
|
4012
4024
|
log$2.warn(`Integration ${id} is in error state — waiting for reinstall request`);
|
|
4013
4025
|
report.errors.push({
|
|
4014
4026
|
integrationId: id,
|
|
@@ -4126,6 +4138,8 @@ var CloudClient = class {
|
|
|
4126
4138
|
onRuntimeRestartNeeded = null;
|
|
4127
4139
|
onReconciliationComplete = null;
|
|
4128
4140
|
reconciliationEngine = null;
|
|
4141
|
+
reconciling = false;
|
|
4142
|
+
pendingDesiredState = null;
|
|
4129
4143
|
constructor(config) {
|
|
4130
4144
|
this.config = config;
|
|
4131
4145
|
}
|
|
@@ -4189,6 +4203,8 @@ var CloudClient = class {
|
|
|
4189
4203
|
this.ws = null;
|
|
4190
4204
|
}
|
|
4191
4205
|
this.registered = false;
|
|
4206
|
+
this.reconciling = false;
|
|
4207
|
+
this.pendingDesiredState = null;
|
|
4192
4208
|
logger$1.debug("Cloud client stopped");
|
|
4193
4209
|
}
|
|
4194
4210
|
/**
|
|
@@ -4348,24 +4364,47 @@ var CloudClient = class {
|
|
|
4348
4364
|
logger$1.warn("Cloud: DESIRED_STATE received but no integration manager set — skipping reconciliation");
|
|
4349
4365
|
return;
|
|
4350
4366
|
}
|
|
4367
|
+
if (this.reconciling) {
|
|
4368
|
+
logger$1.info("Cloud: reconciliation in progress — queuing latest desired state");
|
|
4369
|
+
this.pendingDesiredState = msg;
|
|
4370
|
+
return;
|
|
4371
|
+
}
|
|
4372
|
+
this.reconciling = true;
|
|
4351
4373
|
try {
|
|
4352
|
-
|
|
4353
|
-
logger$1.info({
|
|
4354
|
-
installed: report.installed.length,
|
|
4355
|
-
activated: report.activated.length,
|
|
4356
|
-
deactivated: report.deactivated.length,
|
|
4357
|
-
uninstalled: report.uninstalled.length,
|
|
4358
|
-
errors: report.errors.length
|
|
4359
|
-
}, "Cloud: reconciliation complete");
|
|
4360
|
-
const reportMsg = createReconciliationReport(report.results);
|
|
4361
|
-
this.send(reportMsg);
|
|
4362
|
-
if ((report.installed.length > 0 || report.uninstalled.length > 0 || report.configApplied) && this.onRuntimeRestartNeeded) this.onRuntimeRestartNeeded();
|
|
4363
|
-
this.onReconciliationComplete?.();
|
|
4374
|
+
await this.runReconciliation(msg);
|
|
4364
4375
|
} catch (err) {
|
|
4365
4376
|
const message = err instanceof Error ? err.message : String(err);
|
|
4366
4377
|
logger$1.error({ err: message }, "Cloud: reconciliation failed");
|
|
4378
|
+
} finally {
|
|
4379
|
+
while (this.pendingDesiredState) {
|
|
4380
|
+
const next = this.pendingDesiredState;
|
|
4381
|
+
this.pendingDesiredState = null;
|
|
4382
|
+
logger$1.info({ count: next.integrations.length }, "Cloud: processing queued DESIRED_STATE");
|
|
4383
|
+
try {
|
|
4384
|
+
await this.runReconciliation(next);
|
|
4385
|
+
} catch (err) {
|
|
4386
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
4387
|
+
logger$1.error({ err: message }, "Cloud: queued reconciliation failed");
|
|
4388
|
+
}
|
|
4389
|
+
}
|
|
4390
|
+
this.reconciling = false;
|
|
4367
4391
|
}
|
|
4368
4392
|
}
|
|
4393
|
+
async runReconciliation(msg) {
|
|
4394
|
+
if (!this.reconciliationEngine) return;
|
|
4395
|
+
const report = await this.reconciliationEngine.reconcile(msg.integrations);
|
|
4396
|
+
logger$1.info({
|
|
4397
|
+
installed: report.installed.length,
|
|
4398
|
+
activated: report.activated.length,
|
|
4399
|
+
deactivated: report.deactivated.length,
|
|
4400
|
+
uninstalled: report.uninstalled.length,
|
|
4401
|
+
errors: report.errors.length
|
|
4402
|
+
}, "Cloud: reconciliation complete");
|
|
4403
|
+
const reportMsg = createReconciliationReport(report.results);
|
|
4404
|
+
this.send(reportMsg);
|
|
4405
|
+
if ((report.installed.length > 0 || report.uninstalled.length > 0 || report.configApplied) && this.onRuntimeRestartNeeded) this.onRuntimeRestartNeeded();
|
|
4406
|
+
this.onReconciliationComplete?.();
|
|
4407
|
+
}
|
|
4369
4408
|
send(msg) {
|
|
4370
4409
|
if (this.ws?.readyState === WebSocket.OPEN) this.ws.send(JSON.stringify(msg));
|
|
4371
4410
|
else logger$1.debug({ readyState: this.ws?.readyState }, "Cloud: send skipped — WebSocket not open");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfe.ai/gateway",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35",
|
|
4
4
|
"description": "Alfe local gateway daemon — persistent control plane for agent integrations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@alfe.ai/ai-proxy-local": "^0.0.7",
|
|
26
26
|
"@alfe.ai/config": "^0.0.7",
|
|
27
27
|
"@alfe.ai/integration-manifest": "^0.0.9",
|
|
28
|
-
"@alfe.ai/integrations": "^0.0.
|
|
28
|
+
"@alfe.ai/integrations": "^0.0.23"
|
|
29
29
|
},
|
|
30
30
|
"license": "UNLICENSED",
|
|
31
31
|
"scripts": {
|