@fastgpt-sdk/sandbox-adapter 0.0.37 → 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.
@@ -45,6 +45,7 @@ export declare class SealosDevboxAdapter extends BaseSandboxAdapter {
45
45
  execute(command: string, options?: ExecuteOptions): Promise<ExecuteResult>;
46
46
  getEndpoint(selector: SandboxEndpointSelector): Promise<Endpoint>;
47
47
  getProxyTarget(service?: SandboxProxyService): Promise<SandboxProxyTarget>;
48
+ private waitForCodeServerHealthz;
48
49
  private getHttpgateTarget;
49
50
  private getGatewayUniqueID;
50
51
  private getHttpgateDomain;
package/dist/index.cjs CHANGED
@@ -45924,6 +45924,9 @@ class SealosDevboxAdapter extends BaseSandboxAdapter {
45924
45924
  async getEndpoint(selector) {
45925
45925
  const port = typeof selector === "number" ? selector : SEALOS_DEVBOX_CODE_SERVER_PORT;
45926
45926
  const target = await this.getHttpgateTarget(port);
45927
+ if (selector === "code-server") {
45928
+ await this.waitForCodeServerHealthz(target);
45929
+ }
45927
45930
  const url = new URL(target.origin);
45928
45931
  return {
45929
45932
  host: url.host,
@@ -45945,6 +45948,30 @@ class SealosDevboxAdapter extends BaseSandboxAdapter {
45945
45948
  ...target.password ? { password: target.password } : {}
45946
45949
  };
45947
45950
  }
45951
+ async waitForCodeServerHealthz(target) {
45952
+ const healthUrl = joinUrlPath(joinUrlPath(target.origin, target.basePath), "/healthz");
45953
+ const timeoutMs = 60000;
45954
+ const intervalMs = 500;
45955
+ const requestTimeoutMs = 3000;
45956
+ const deadline = Date.now() + timeoutMs;
45957
+ let lastResult = "not checked";
45958
+ while (Date.now() < deadline) {
45959
+ try {
45960
+ const res = await fetch(healthUrl, {
45961
+ method: "GET",
45962
+ signal: AbortSignal.timeout(requestTimeoutMs)
45963
+ });
45964
+ if (res.status >= 200 && res.status < 400) {
45965
+ return;
45966
+ }
45967
+ lastResult = `status ${res.status}`;
45968
+ } catch (error) {
45969
+ lastResult = error instanceof Error ? error.message : String(error);
45970
+ }
45971
+ await this.sleep(intervalMs);
45972
+ }
45973
+ throw new ConnectionError(`Devbox code-server health check ${healthUrl} did not become ready within ${timeoutMs}ms. Last result: ${lastResult}`, this.config.baseUrl);
45974
+ }
45948
45975
  async getHttpgateTarget(port) {
45949
45976
  const res = await this.api.info(this._id);
45950
45977
  if (res.code !== 200 || !res.data) {
package/dist/index.js CHANGED
@@ -45908,6 +45908,9 @@ class SealosDevboxAdapter extends BaseSandboxAdapter {
45908
45908
  async getEndpoint(selector) {
45909
45909
  const port = typeof selector === "number" ? selector : SEALOS_DEVBOX_CODE_SERVER_PORT;
45910
45910
  const target = await this.getHttpgateTarget(port);
45911
+ if (selector === "code-server") {
45912
+ await this.waitForCodeServerHealthz(target);
45913
+ }
45911
45914
  const url = new URL(target.origin);
45912
45915
  return {
45913
45916
  host: url.host,
@@ -45929,6 +45932,30 @@ class SealosDevboxAdapter extends BaseSandboxAdapter {
45929
45932
  ...target.password ? { password: target.password } : {}
45930
45933
  };
45931
45934
  }
45935
+ async waitForCodeServerHealthz(target) {
45936
+ const healthUrl = joinUrlPath(joinUrlPath(target.origin, target.basePath), "/healthz");
45937
+ const timeoutMs = 60000;
45938
+ const intervalMs = 500;
45939
+ const requestTimeoutMs = 3000;
45940
+ const deadline = Date.now() + timeoutMs;
45941
+ let lastResult = "not checked";
45942
+ while (Date.now() < deadline) {
45943
+ try {
45944
+ const res = await fetch(healthUrl, {
45945
+ method: "GET",
45946
+ signal: AbortSignal.timeout(requestTimeoutMs)
45947
+ });
45948
+ if (res.status >= 200 && res.status < 400) {
45949
+ return;
45950
+ }
45951
+ lastResult = `status ${res.status}`;
45952
+ } catch (error) {
45953
+ lastResult = error instanceof Error ? error.message : String(error);
45954
+ }
45955
+ await this.sleep(intervalMs);
45956
+ }
45957
+ throw new ConnectionError(`Devbox code-server health check ${healthUrl} did not become ready within ${timeoutMs}ms. Last result: ${lastResult}`, this.config.baseUrl);
45958
+ }
45932
45959
  async getHttpgateTarget(port) {
45933
45960
  const res = await this.api.info(this._id);
45934
45961
  if (res.code !== 200 || !res.data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastgpt-sdk/sandbox-adapter",
3
- "version": "0.0.37",
3
+ "version": "0.0.38",
4
4
  "description": "Unified abstraction layer for cloud sandbox providers with adapter pattern and feature polyfilling",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",