@selvajs/compute 5.0.0-beta.9 → 5.0.0

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/core.js CHANGED
@@ -1 +1 @@
1
- export { P as ComputeError, T as DEFAULT_BLOCKED_HOST, F as ErrorCodes, d as classifyProbeFailure, y as decodeBase64ToBinary, t as downloadFileData, n as downloadFileDataByRoot, j as enableDebugLogging, r as extractFilesFromComputeResponse, l as fetchCompute, M as getLogger, a as groupFilesByRoot, k as hasField, s as isDefinitionRef, A as readField, N as setLogger, o as subFolderSegments, E as validateServerUrl } from "./handle-files-fKtSlWT2.js";
1
+ export { P as ComputeError, T as DEFAULT_BLOCKED_HOST, F as ErrorCodes, d as classifyProbeFailure, y as decodeBase64ToBinary, t as downloadFileData, n as downloadFileDataByRoot, j as enableDebugLogging, r as extractFilesFromComputeResponse, l as fetchCompute, M as getLogger, a as groupFilesByRoot, k as hasField, s as isDefinitionRef, A as readField, N as setLogger, o as subFolderSegments, E as validateServerUrl } from "./handle-files-D-4X4Uh_.js";
@@ -4,6 +4,15 @@ interface ServerVersion {
4
4
  compute: string;
5
5
  git_sha: string | null;
6
6
  }
7
+ /** What `GET /limits` reports. Only the VektorNode fork answers it. */
8
+ interface ServerLimits {
9
+ /** Longest the server lets one request run (`RHINO_COMPUTE_TIMEOUT`, `--timeout`). */
10
+ timeoutSeconds: number;
11
+ /** Largest request body it accepts (`RHINO_COMPUTE_MAX_REQUEST_SIZE`, `--max-request-size`). */
12
+ maxRequestBytes: number;
13
+ /** A stale definition pointer answers `definition_not_cached`, so pointer reuse is safe. */
14
+ signalsStaleDefinition: boolean;
15
+ }
7
16
  interface ServerStats {
8
17
  isOnline: boolean;
9
18
  version?: ServerVersion;
@@ -106,6 +115,12 @@ declare class ComputeServerStats {
106
115
  getActiveChildren(options?: {
107
116
  initialize?: boolean;
108
117
  }): Promise<number | null>;
118
+ /**
119
+ * The server's request limits, or `null` when it can't report them: a standard rhino.compute
120
+ * has no `/limits`, and neither does an older fork. A missing route is expected, so it isn't
121
+ * logged as a failure.
122
+ */
123
+ getLimits(): Promise<ServerLimits | null>;
109
124
  /**
110
125
  * Get the server version information.
111
126
  *
@@ -1316,5 +1331,5 @@ export declare class TreeBuilder {
1316
1331
  private static hasValidValue;
1317
1332
  private static clampValue;
1318
1333
  }
1319
- export { type BooleanInputType, type CacheOptions, type CacheStats, type ColorInputType, ComputeServerStats, type CreateClientOptions, type DataItem, type DataTree, type DataTreeDefault, type DataTreePath, type DataTreeValue, type DefaultValue, type FileInputType, type GeometryInputType, type GetValuesOptions, type GetValuesResult, GrasshopperClient, type GrasshopperComputeConfig, type GrasshopperComputeResponse, type GrasshopperParsedIO, type GrasshopperParsedIORaw, GrasshopperResponseProcessor, type InnerTreeData, type InputParam, type InputParamSchema, type InputParseError, type NumericInputType, type OutputParamSchema, type ParsedContext, type RhinoDecodeError, type RhinoModelUnit, type RhinoRuntime, type SchedulerMode, type SchedulerSolveOptions, type SchemaEndpointResult, type SelvaEventTarget, type SelvaResponseBlock, type ServerStats, type ServerVersion, type SolveContext, type SolveDetail, type SolveExecutor, type SolveOptions, type SolveResult, type SolveSchedulerOptions, type TextInputType, type TreeValueEntry, type ValueListInputType };
1334
+ export { type BooleanInputType, type CacheOptions, type CacheStats, type ColorInputType, ComputeServerStats, type CreateClientOptions, type DataItem, type DataTree, type DataTreeDefault, type DataTreePath, type DataTreeValue, type DefaultValue, type FileInputType, type GeometryInputType, type GetValuesOptions, type GetValuesResult, GrasshopperClient, type GrasshopperComputeConfig, type GrasshopperComputeResponse, type GrasshopperParsedIO, type GrasshopperParsedIORaw, GrasshopperResponseProcessor, type InnerTreeData, type InputParam, type InputParamSchema, type InputParseError, type NumericInputType, type OutputParamSchema, type ParsedContext, type RhinoDecodeError, type RhinoModelUnit, type RhinoRuntime, type SchedulerMode, type SchedulerSolveOptions, type SchemaEndpointResult, type SelvaEventTarget, type SelvaResponseBlock, type ServerLimits, type ServerStats, type ServerVersion, type SolveContext, type SolveDetail, type SolveExecutor, type SolveOptions, type SolveResult, type SolveSchedulerOptions, type TextInputType, type TreeValueEntry, type ValueListInputType };
1320
1335
  //# sourceMappingURL=grasshopper.d.ts.map
@@ -1,4 +1,4 @@
1
- import { A as readField, C as withJsonContentType, D as tryParseJson, E as validateServerUrl, F as ErrorCodes, I as abortedByCaller, L as sleep, M as getLogger, O as redactUrl, P as ComputeError, S as buildAuthHeaders, _ as readBodyText, b as detectBase64Payload, c as isDefinitionUrl, d as classifyProbeFailure, f as isRedirect, g as raceSignal, h as composeSignal, i as isBase64Flag, k as hasField, l as fetchCompute, m as setResponseWireSize, p as getResponseWireSize, s as isDefinitionRef, t as downloadFileData, u as validateNumbers, v as base64ByteArray, w as warnIfClientSide, x as encodeStringToBase64 } from "./handle-files-fKtSlWT2.js";
1
+ import { A as readField, C as withJsonContentType, D as tryParseJson, E as validateServerUrl, F as ErrorCodes, I as abortedByCaller, L as sleep, M as getLogger, O as redactUrl, P as ComputeError, S as buildAuthHeaders, _ as readBodyText, b as detectBase64Payload, c as isDefinitionUrl, d as classifyProbeFailure, f as isRedirect, g as raceSignal, h as composeSignal, i as isBase64Flag, k as hasField, l as fetchCompute, m as setResponseWireSize, p as getResponseWireSize, s as isDefinitionRef, t as downloadFileData, u as validateNumbers, v as base64ByteArray, w as warnIfClientSide, x as encodeStringToBase64 } from "./handle-files-D-4X4Uh_.js";
2
2
  // src/grasshopper/server/compute-server-stats.ts
3
3
  /**
4
4
  * Server health and control: liveness, version, child processes, cache purges.
@@ -160,6 +160,36 @@ var ComputeServerStats = class ComputeServerStats {
160
160
  return parseInt(text, 10);
161
161
  }
162
162
  /**
163
+ * The server's request limits, or `null` when it can't report them: a standard rhino.compute
164
+ * has no `/limits`, and neither does an older fork. A missing route is expected, so it isn't
165
+ * logged as a failure.
166
+ */
167
+ async getLimits() {
168
+ this.ensureNotDisposed();
169
+ let text;
170
+ try {
171
+ const response = await this.fetchWithTimeout(`${this.serverUrl}/limits`);
172
+ if (!response.ok) {
173
+ await response.body?.cancel().catch(() => {});
174
+ return null;
175
+ }
176
+ const read = await readBodyText(response, ComputeServerStats.MAX_BODY_BYTES);
177
+ if (read.truncated) return null;
178
+ text = read.text;
179
+ } catch (err) {
180
+ getLogger().debug(`[ComputeServerStats] GET /limits errored: ${describeProbeError(err)}`);
181
+ return null;
182
+ }
183
+ const json = tryParseJson(text);
184
+ const positive = (n) => typeof n === "number" && Number.isFinite(n) && n > 0;
185
+ if (!json || !positive(json.timeoutSeconds) || !positive(json.maxRequestBytes)) return null;
186
+ return {
187
+ timeoutSeconds: json.timeoutSeconds,
188
+ maxRequestBytes: json.maxRequestBytes,
189
+ signalsStaleDefinition: json.signalsStaleDefinition === true
190
+ };
191
+ }
192
+ /**
163
193
  * Get the server version information.
164
194
  *
165
195
  * @returns Version object with rhino, compute, and git_sha, or null if unavailable