@alfe.ai/gateway 0.0.39 → 0.0.41

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 CHANGED
@@ -87,6 +87,7 @@ const ID_PREFIXES = {
87
87
  identityNote: "ino",
88
88
  identityTag: "itg",
89
89
  identityAlias: "ial",
90
+ identityVerification: "ivf",
90
91
  attachment: "att",
91
92
  run: "run",
92
93
  request: "req",
@@ -521,8 +522,15 @@ var IntegrationsService = class {
521
522
  getMobileNumber(agentId) {
522
523
  return this.client.request(`/mobile/numbers?agentId=${encodeURIComponent(agentId)}`);
523
524
  }
524
- disconnectGoogle(agentId) {
525
- return this.client.request(`/google/agents/${encodeURIComponent(agentId)}/account`, { method: "DELETE" });
525
+ disconnectGoogle(agentId, email) {
526
+ const query = email ? `?email=${encodeURIComponent(email)}` : "";
527
+ return this.client.request(`/google/agents/${encodeURIComponent(agentId)}/account${query}`, { method: "DELETE" });
528
+ }
529
+ setDefaultGoogleAccount(agentId, email) {
530
+ return this.client.request(`/google/agents/${encodeURIComponent(agentId)}/account/default`, {
531
+ method: "PUT",
532
+ body: JSON.stringify({ email })
533
+ });
526
534
  }
527
535
  getAtlassianSites(agentId) {
528
536
  return this.client.request(`/atlassian/agents/${encodeURIComponent(agentId)}/sites`);
@@ -3239,6 +3247,7 @@ enumValues({
3239
3247
  MiniMax: "minimax",
3240
3248
  Mistral: "mistral",
3241
3249
  XAI: "xai",
3250
+ Zhipu: "zhipu",
3242
3251
  OpenRouter: "openrouter",
3243
3252
  ElevenLabs: "elevenlabs",
3244
3253
  Twilio: "twilio"
@@ -3288,7 +3297,6 @@ enumValues({
3288
3297
  });
3289
3298
  enumValues({
3290
3299
  Public: "public",
3291
- Dev: "dev",
3292
3300
  Hidden: "hidden"
3293
3301
  });
3294
3302
  enumValues({
@@ -3460,6 +3468,11 @@ const XAIModel = {
3460
3468
  Grok41Fast: "grok-4.1-fast"
3461
3469
  };
3462
3470
  const XAI_MODELS = enumValues(XAIModel);
3471
+ const ZhipuModel = {
3472
+ GLM51: "glm-5-1",
3473
+ GLM51Air: "glm-5-1-air"
3474
+ };
3475
+ const ZHIPU_MODELS = enumValues(ZhipuModel);
3463
3476
  AnthropicModel.Sonnet;
3464
3477
  [
3465
3478
  ...ANTHROPIC_MODELS,
@@ -3468,7 +3481,8 @@ AnthropicModel.Sonnet;
3468
3481
  ...GOOGLE_MODELS,
3469
3482
  ...MINIMAX_MODELS,
3470
3483
  ...MISTRAL_MODELS,
3471
- ...XAI_MODELS
3484
+ ...XAI_MODELS,
3485
+ ...ZHIPU_MODELS
3472
3486
  ];
3473
3487
  _enum(ANTHROPIC_MODELS);
3474
3488
  _enum(OPENAI_MODELS);
@@ -3477,6 +3491,7 @@ _enum(GOOGLE_MODELS);
3477
3491
  _enum(MINIMAX_MODELS);
3478
3492
  _enum(MISTRAL_MODELS);
3479
3493
  _enum(XAI_MODELS);
3494
+ _enum(ZHIPU_MODELS);
3480
3495
  _enum([
3481
3496
  ...ANTHROPIC_MODELS,
3482
3497
  ...OPENAI_MODELS,
@@ -3484,10 +3499,11 @@ _enum([
3484
3499
  ...GOOGLE_MODELS,
3485
3500
  ...MINIMAX_MODELS,
3486
3501
  ...MISTRAL_MODELS,
3487
- ...XAI_MODELS
3502
+ ...XAI_MODELS,
3503
+ ...ZHIPU_MODELS
3488
3504
  ]);
3489
- AnthropicModel.Opus, AnthropicModel.Sonnet, AnthropicModel.Haiku, OpenAIModel.GPT4o, OpenAIModel.GPT4oMini, OpenAIModel.O3, OpenAIModel.GPT41, OpenAIModel.GPT41Mini, OpenAIModel.GPT41Nano, OpenAIModel.GPT54, OpenAIModel.GPT54Mini, OpenAIModel.GPT54Nano, OpenAIModel.GPT54Pro, OpenAIModel.O3Mini, OpenAIModel.O4Mini, DeepSeekModel.Chat, DeepSeekModel.Reasoner, GoogleModel.Gemini25Pro, GoogleModel.Gemini25Flash, GoogleModel.Gemini25FlashLite, GoogleModel.Gemini20Flash, MiniMaxModel.M27, MiniMaxModel.M25, MistralModel.Large, MistralModel.Small, MistralModel.Codestral, XAIModel.Grok4, XAIModel.Grok41Fast;
3490
- AnthropicModel.Opus, AnthropicModel.Sonnet, AnthropicModel.Haiku, OpenAIModel.GPT4o, OpenAIModel.GPT4oMini, OpenAIModel.O3, OpenAIModel.GPT41, OpenAIModel.GPT41Mini, OpenAIModel.GPT41Nano, OpenAIModel.GPT54, OpenAIModel.GPT54Mini, OpenAIModel.GPT54Nano, OpenAIModel.GPT54Pro, OpenAIModel.O3Mini, OpenAIModel.O4Mini, DeepSeekModel.Chat, DeepSeekModel.Reasoner, GoogleModel.Gemini25Pro, GoogleModel.Gemini25Flash, GoogleModel.Gemini25FlashLite, GoogleModel.Gemini20Flash, MiniMaxModel.M27, MiniMaxModel.M25, MistralModel.Large, MistralModel.Small, MistralModel.Codestral, XAIModel.Grok4, XAIModel.Grok41Fast;
3505
+ AnthropicModel.Opus, AnthropicModel.Sonnet, AnthropicModel.Haiku, OpenAIModel.GPT4o, OpenAIModel.GPT4oMini, OpenAIModel.O3, OpenAIModel.GPT41, OpenAIModel.GPT41Mini, OpenAIModel.GPT41Nano, OpenAIModel.GPT54, OpenAIModel.GPT54Mini, OpenAIModel.GPT54Nano, OpenAIModel.GPT54Pro, OpenAIModel.O3Mini, OpenAIModel.O4Mini, DeepSeekModel.Chat, DeepSeekModel.Reasoner, GoogleModel.Gemini25Pro, GoogleModel.Gemini25Flash, GoogleModel.Gemini25FlashLite, GoogleModel.Gemini20Flash, MiniMaxModel.M27, MiniMaxModel.M25, MistralModel.Large, MistralModel.Small, MistralModel.Codestral, XAIModel.Grok4, XAIModel.Grok41Fast, ZhipuModel.GLM51, ZhipuModel.GLM51Air;
3506
+ AnthropicModel.Opus, AnthropicModel.Sonnet, AnthropicModel.Haiku, OpenAIModel.GPT4o, OpenAIModel.GPT4oMini, OpenAIModel.O3, OpenAIModel.GPT41, OpenAIModel.GPT41Mini, OpenAIModel.GPT41Nano, OpenAIModel.GPT54, OpenAIModel.GPT54Mini, OpenAIModel.GPT54Nano, OpenAIModel.GPT54Pro, OpenAIModel.O3Mini, OpenAIModel.O4Mini, DeepSeekModel.Chat, DeepSeekModel.Reasoner, GoogleModel.Gemini25Pro, GoogleModel.Gemini25Flash, GoogleModel.Gemini25FlashLite, GoogleModel.Gemini20Flash, MiniMaxModel.M27, MiniMaxModel.M25, MistralModel.Large, MistralModel.Small, MistralModel.Codestral, XAIModel.Grok4, XAIModel.Grok41Fast, ZhipuModel.GLM51, ZhipuModel.GLM51Air;
3491
3507
  enumValues({
3492
3508
  PendingChallenge: "pending_challenge",
3493
3509
  Creating: "creating",
@@ -3875,7 +3891,7 @@ function createServiceRegister(agentId, capabilities = [
3875
3891
  "integrations",
3876
3892
  "lifecycle",
3877
3893
  "health"
3878
- ], cliVersion) {
3894
+ ], cliVersion, runtimeVersion) {
3879
3895
  const msg = {
3880
3896
  type: "SERVICE_REGISTER",
3881
3897
  serviceId: `gateway-daemon-${agentId}`,
@@ -3883,6 +3899,7 @@ function createServiceRegister(agentId, capabilities = [
3883
3899
  capabilities
3884
3900
  };
3885
3901
  if (cliVersion) msg.cliVersion = cliVersion;
3902
+ if (runtimeVersion) msg.runtimeVersion = runtimeVersion;
3886
3903
  return msg;
3887
3904
  }
3888
3905
  /**
@@ -4279,6 +4296,14 @@ var CloudClient = class {
4279
4296
  if (this.lastPong === 0) return -1;
4280
4297
  return Date.now() - this.lastPong;
4281
4298
  }
4299
+ /**
4300
+ * Update the runtime version and re-send SERVICE_REGISTER.
4301
+ * Used after a runtime upgrade to immediately persist the new version.
4302
+ */
4303
+ updateRuntimeVersionAndReRegister(runtimeVersion) {
4304
+ this.config.runtimeVersion = runtimeVersion;
4305
+ if (this.ws?.readyState === WebSocket.OPEN) this.sendRegister();
4306
+ }
4282
4307
  doConnect() {
4283
4308
  if (this.closed) {
4284
4309
  logger$1.debug("Cloud: doConnect skipped — client is closed");
@@ -4330,11 +4355,12 @@ var CloudClient = class {
4330
4355
  });
4331
4356
  }
4332
4357
  sendRegister() {
4333
- const msg = createServiceRegister(this.config.agentId, void 0, this.config.cliVersion);
4358
+ const msg = createServiceRegister(this.config.agentId, void 0, this.config.cliVersion, this.config.runtimeVersion);
4334
4359
  logger$1.debug({
4335
4360
  serviceId: msg.serviceId,
4336
4361
  agentIds: msg.agentIds,
4337
- cliVersion: msg.cliVersion
4362
+ cliVersion: msg.cliVersion,
4363
+ runtimeVersion: msg.runtimeVersion
4338
4364
  }, "Cloud: sending SERVICE_REGISTER");
4339
4365
  this.send(msg);
4340
4366
  logger$1.info({ serviceId: msg.serviceId }, "Sent SERVICE_REGISTER");
@@ -20477,6 +20503,8 @@ let cloudConnected = false;
20477
20503
  let shuttingDown = false;
20478
20504
  let commandRegistry;
20479
20505
  let resolvedCliVersion;
20506
+ let resolvedRuntimeVersion;
20507
+ let upgradingRuntime = false;
20480
20508
  /**
20481
20509
  * Resolve the installed @alfe.ai/cli version.
20482
20510
  *
@@ -20507,6 +20535,19 @@ async function getCliVersion() {
20507
20535
  logger$1.debug("Could not resolve @alfe.ai/cli version");
20508
20536
  }
20509
20537
  /**
20538
+ * Resolve the installed runtime (OpenClaw) version.
20539
+ * Runs `openclaw --version` and returns the trimmed output.
20540
+ */
20541
+ async function getRuntimeVersion() {
20542
+ try {
20543
+ const { stdout } = await execFileAsync("openclaw", ["--version"]);
20544
+ return stdout.trim() || void 0;
20545
+ } catch {
20546
+ logger$1.debug("Could not resolve openclaw runtime version");
20547
+ return;
20548
+ }
20549
+ }
20550
+ /**
20510
20551
  * Flush pino's async transport and exit.
20511
20552
  * process.exit() can drop buffered log lines — this ensures they're written first.
20512
20553
  */
@@ -20601,7 +20642,11 @@ async function startDaemon() {
20601
20642
  await flushAndExit(1);
20602
20643
  }
20603
20644
  resolvedCliVersion = await getCliVersion();
20604
- logger$1.info({ cliVersion: resolvedCliVersion }, "Resolved CLI version");
20645
+ resolvedRuntimeVersion = await getRuntimeVersion();
20646
+ logger$1.info({
20647
+ cliVersion: resolvedCliVersion,
20648
+ runtimeVersion: resolvedRuntimeVersion
20649
+ }, "Resolved versions");
20605
20650
  logger$1.debug({
20606
20651
  wsUrl: config.gatewayWsUrl,
20607
20652
  agentId: config.agentId
@@ -20610,7 +20655,8 @@ async function startDaemon() {
20610
20655
  wsUrl: config.gatewayWsUrl,
20611
20656
  apiKey: config.apiKey,
20612
20657
  agentId: config.agentId,
20613
- cliVersion: resolvedCliVersion
20658
+ cliVersion: resolvedCliVersion,
20659
+ runtimeVersion: resolvedRuntimeVersion
20614
20660
  });
20615
20661
  cloudClient.setCommandHandler(handleCloudCommand);
20616
20662
  cloudClient.setConnectionChangeHandler((connected) => {
@@ -20748,6 +20794,45 @@ async function handleCloudCommand(command) {
20748
20794
  }
20749
20795
  };
20750
20796
  }
20797
+ if (command.command === "runtime.update") {
20798
+ if (upgradingRuntime) return {
20799
+ type: "COMMAND_ACK",
20800
+ commandId: command.commandId,
20801
+ status: "error",
20802
+ result: {
20803
+ code: "ALREADY_UPGRADING",
20804
+ message: "Runtime upgrade already in progress"
20805
+ }
20806
+ };
20807
+ const version = command.payload?.version ?? "latest";
20808
+ upgradingRuntime = true;
20809
+ setTimeout(() => {
20810
+ (async () => {
20811
+ try {
20812
+ const { upgradeRuntime } = await import("./runtime-upgrade.js");
20813
+ if ((await upgradeRuntime(version, runtimeProcess)).success) {
20814
+ resolvedRuntimeVersion = await getRuntimeVersion();
20815
+ if (!resolvedRuntimeVersion) logger$1.warn({ requestedVersion: version }, "Could not detect runtime version after upgrade — using requested version");
20816
+ logger$1.info({ runtimeVersion: resolvedRuntimeVersion ?? version }, "Runtime version updated after upgrade");
20817
+ cloudClient.updateRuntimeVersionAndReRegister(resolvedRuntimeVersion ?? version);
20818
+ }
20819
+ } catch (err) {
20820
+ logger$1.error({ err: err instanceof Error ? err.message : String(err) }, "Runtime upgrade failed");
20821
+ } finally {
20822
+ upgradingRuntime = false;
20823
+ }
20824
+ })();
20825
+ }, 100);
20826
+ return {
20827
+ type: "COMMAND_ACK",
20828
+ commandId: command.commandId,
20829
+ status: "ok",
20830
+ result: {
20831
+ upgrading: true,
20832
+ version
20833
+ }
20834
+ };
20835
+ }
20751
20836
  if (command.command === "integration.status") {
20752
20837
  const payload = command.payload;
20753
20838
  try {
@@ -20966,7 +21051,8 @@ function handleStatus() {
20966
21051
  status: "running",
20967
21052
  pid: process.pid,
20968
21053
  uptime: (Date.now() - startedAt) / 1e3,
20969
- version: "0.1.0"
21054
+ version: "0.1.0",
21055
+ runtimeVersion: resolvedRuntimeVersion
20970
21056
  },
20971
21057
  cloud: {
20972
21058
  status: cloudConnected ? "connected" : "disconnected",
@@ -21075,6 +21161,7 @@ function formatHealthReport(health) {
21075
21161
  const lines = [];
21076
21162
  const daemonIcon = health.daemon.status === "running" ? "✓" : "✗";
21077
21163
  lines.push(` Gateway daemon ${daemonIcon} ${health.daemon.status}` + (health.daemon.uptime ? ` (uptime: ${formatUptime(health.daemon.uptime)})` : "") + (health.daemon.version ? ` v${health.daemon.version}` : ""));
21164
+ if (health.daemon.runtimeVersion) lines.push(` Runtime version ✓ v${health.daemon.runtimeVersion}`);
21078
21165
  const cloudIcon = health.cloud.status === "connected" ? "✓" : "✗";
21079
21166
  lines.push(` Cloud connection ${cloudIcon} ${health.cloud.status}` + (health.cloud.latencyMs !== void 0 ? ` (latency: ${String(health.cloud.latencyMs)}ms)` : ""));
21080
21167
  const proxyIcon = health.aiProxy.status === "running" ? "✓" : "✗";
@@ -0,0 +1,63 @@
1
+ import { n as logger } from "./logger.js";
2
+ import { execFile } from "node:child_process";
3
+ import { promisify } from "node:util";
4
+ //#region src/runtime-upgrade.ts
5
+ /**
6
+ * Runtime upgrade — npm install then cycle the RuntimeProcess.
7
+ *
8
+ * Unlike CLI upgrade (which exits the daemon for systemd restart),
9
+ * runtime upgrade keeps the daemon running and just restarts the child process.
10
+ *
11
+ * Flow:
12
+ * 1. Stop the RuntimeProcess child (SIGTERM + grace period)
13
+ * 2. npm install -g openclaw@{version}
14
+ * 3. Restart the RuntimeProcess child
15
+ *
16
+ * On npm failure, the runtime is restarted on the old version.
17
+ */
18
+ const execFileAsync = promisify(execFile);
19
+ async function upgradeRuntime(version, runtimeProcess) {
20
+ logger.info({ version }, "Upgrading OpenClaw runtime...");
21
+ if (runtimeProcess) {
22
+ logger.info("Stopping runtime for upgrade...");
23
+ await runtimeProcess.stop();
24
+ }
25
+ try {
26
+ const { stdout, stderr } = await execFileAsync("npm", [
27
+ "install",
28
+ "-g",
29
+ `openclaw@${version}`
30
+ ], { timeout: 12e4 });
31
+ if (stdout) logger.debug({ stdout: stdout.trim() }, "npm install stdout");
32
+ if (stderr) logger.debug({ stderr: stderr.trim() }, "npm install stderr");
33
+ logger.info({ version }, "OpenClaw runtime upgraded successfully");
34
+ } catch (err) {
35
+ const message = err instanceof Error ? err.message : String(err);
36
+ logger.error({
37
+ err: message,
38
+ version
39
+ }, "Runtime upgrade npm install failed");
40
+ if (runtimeProcess) try {
41
+ logger.info("Restarting runtime on previous version after failed upgrade...");
42
+ await runtimeProcess.restart();
43
+ } catch (restartErr) {
44
+ const restartMsg = restartErr instanceof Error ? restartErr.message : String(restartErr);
45
+ logger.error({ err: restartMsg }, "Failed to restart runtime after failed upgrade");
46
+ }
47
+ return {
48
+ success: false,
49
+ version,
50
+ error: message
51
+ };
52
+ }
53
+ if (runtimeProcess) {
54
+ logger.info("Restarting runtime after upgrade...");
55
+ await runtimeProcess.restart();
56
+ }
57
+ return {
58
+ success: true,
59
+ version
60
+ };
61
+ }
62
+ //#endregion
63
+ export { upgradeRuntime };
@@ -111,6 +111,7 @@ interface DaemonHealth {
111
111
  pid?: number;
112
112
  uptime?: number;
113
113
  version?: string;
114
+ runtimeVersion?: string;
114
115
  };
115
116
  cloud: {
116
117
  status: 'connected' | 'disconnected' | 'unknown';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfe.ai/gateway",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
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.25"
28
+ "@alfe.ai/integrations": "^0.0.27"
29
29
  },
30
30
  "license": "UNLICENSED",
31
31
  "scripts": {