aws-runtime-bridge 1.3.7 → 1.3.8

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.
@@ -10,4 +10,17 @@ export declare function buildConnectionCheckResponse(connectionKeyMd5: string):
10
10
  error?: string;
11
11
  };
12
12
  };
13
+ export interface SchedulerPingFailureResponse {
14
+ ok: false;
15
+ error: string;
16
+ failureStage: "scheduler_ping";
17
+ runtimeBridge: "healthy";
18
+ schedulerBaseUrl: string;
19
+ hint: string;
20
+ }
21
+ /**
22
+ * 构建调度中心 ping 失败响应。
23
+ * 主流程:保留底层错误与 scheduler 地址,同时明确 bridge 本身已连通、失败点在 bridge 回连调度中心。
24
+ */
25
+ export declare function buildSchedulerPingFailureResponse(error: Error, configuredSchedulerBaseUrl: string): SchedulerPingFailureResponse;
13
26
  //# sourceMappingURL=instance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/routes/instance.ts"],"names":[],"mappings":"AA6BA,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,GAC/D,IAAI,CAEN;AAED,eAAO,MAAM,cAAc,4CAAW,CAAC;AAyBvC,wBAAgB,4BAA4B,CAAC,gBAAgB,EAAE,MAAM,GAAG;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE;QACJ,EAAE,EAAE,OAAO,CAAC;QACZ,aAAa,CAAC,EAAE,SAAS,CAAC;QAC1B,oBAAoB,EAAE,OAAO,CAAC;QAC9B,qBAAqB,EAAE,OAAO,CAAC;QAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAqCA"}
1
+ {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/routes/instance.ts"],"names":[],"mappings":"AA6BA,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,GAC/D,IAAI,CAEN;AAED,eAAO,MAAM,cAAc,4CAAW,CAAC;AAyBvC,wBAAgB,4BAA4B,CAAC,gBAAgB,EAAE,MAAM,GAAG;IACtE,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE;QACJ,EAAE,EAAE,OAAO,CAAC;QACZ,aAAa,CAAC,EAAE,SAAS,CAAC;QAC1B,oBAAoB,EAAE,OAAO,CAAC;QAC9B,qBAAqB,EAAE,OAAO,CAAC;QAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAqCA;AAED,MAAM,WAAW,4BAA4B;IAC3C,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,gBAAgB,CAAC;IAC/B,aAAa,EAAE,SAAS,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,KAAK,EACZ,0BAA0B,EAAE,MAAM,GACjC,4BAA4B,CAiB9B"}
@@ -72,6 +72,25 @@ export function buildConnectionCheckResponse(connectionKeyMd5) {
72
72
  },
73
73
  };
74
74
  }
75
+ /**
76
+ * 构建调度中心 ping 失败响应。
77
+ * 主流程:保留底层错误与 scheduler 地址,同时明确 bridge 本身已连通、失败点在 bridge 回连调度中心。
78
+ */
79
+ export function buildSchedulerPingFailureResponse(error, configuredSchedulerBaseUrl) {
80
+ const trimmedSchedulerBaseUrl = configuredSchedulerBaseUrl.trim();
81
+ const schedulerUrl = trimmedSchedulerBaseUrl || "http://localhost:8080";
82
+ const isLocalhostScheduler = /^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?(?:\/|$)/i.test(schedulerUrl);
83
+ return {
84
+ ok: false,
85
+ error: error.message || "scheduler ping failed",
86
+ failureStage: "scheduler_ping",
87
+ runtimeBridge: "healthy",
88
+ schedulerBaseUrl: schedulerUrl,
89
+ hint: isLocalhostScheduler
90
+ ? "aws-runtime-bridge 已连通,但它回连调度中心失败。请在 bridge 启动环境中将 AWS_RUNTIME_SCHEDULER_BASE_URL 配置为该实例可访问的调度中心地址,例如 http://<server-host>:7380。"
91
+ : "aws-runtime-bridge 已连通,但它回连调度中心失败。请确认 AWS_RUNTIME_SCHEDULER_BASE_URL 指向的调度中心地址可从 bridge 机器访问,并且运行时访问令牌仍有效。",
92
+ };
93
+ }
75
94
  instanceRouter.get("/healthz", (_req, res) => {
76
95
  res.json({
77
96
  ok: true,
@@ -100,11 +119,9 @@ instanceRouter.get("/ping", validateToken, async (_req, res) => {
100
119
  }
101
120
  catch (error) {
102
121
  const err = error;
103
- res.status(502).json({
104
- ok: false,
105
- error: err?.message || "scheduler ping failed",
106
- schedulerBaseUrl,
107
- });
122
+ res
123
+ .status(502)
124
+ .json(buildSchedulerPingFailureResponse(err, schedulerBaseUrl));
108
125
  }
109
126
  });
110
127
  instanceRouter.post("/init-instance", validateToken, async (req, res) => {
@@ -98,4 +98,25 @@ describe('instance route validation', () => {
98
98
  },
99
99
  });
100
100
  });
101
+ it('explains localhost scheduler ping failures with environment variable guidance', async () => {
102
+ const { buildSchedulerPingFailureResponse } = await import('./instance.js');
103
+ const response = buildSchedulerPingFailureResponse(new Error('connect ECONNREFUSED 127.0.0.1:8080'), 'http://localhost:8080');
104
+ expect(response).toEqual({
105
+ ok: false,
106
+ error: 'connect ECONNREFUSED 127.0.0.1:8080',
107
+ failureStage: 'scheduler_ping',
108
+ runtimeBridge: 'healthy',
109
+ schedulerBaseUrl: 'http://localhost:8080',
110
+ hint: expect.stringContaining('AWS_RUNTIME_SCHEDULER_BASE_URL'),
111
+ });
112
+ expect(response.hint).toContain('http://<server-host>:7380');
113
+ });
114
+ it('explains non-localhost scheduler ping failures as reachability or token issues', async () => {
115
+ const { buildSchedulerPingFailureResponse } = await import('./instance.js');
116
+ const response = buildSchedulerPingFailureResponse(new Error('Request failed with status code 401'), 'http://10.0.0.8:7380');
117
+ expect(response.schedulerBaseUrl).toBe('http://10.0.0.8:7380');
118
+ expect(response.failureStage).toBe('scheduler_ping');
119
+ expect(response.runtimeBridge).toBe('healthy');
120
+ expect(response.hint).toContain('运行时访问令牌仍有效');
121
+ });
101
122
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-runtime-bridge",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "description": "AgentsWorkStudio runtime bridge service for machine-level agent runtime integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",