witnora 0.18.0 → 0.18.1

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/onboard.js CHANGED
@@ -61,7 +61,7 @@ export async function runOnboard(options) {
61
61
  const references = localRuntime.references;
62
62
  const modules = references?.sandboxOrigin && references.adapterDigestSha256 && references.probeDigestSha256 && references.fixtureContractDigestSha256
63
63
  ? { sandboxOrigin: references.sandboxOrigin, adapterDigestSha256: references.adapterDigestSha256, probeDigestSha256: references.probeDigestSha256, fixtureContractDigestSha256: references.fixtureContractDigestSha256 }
64
- : await planRuntimeSandboxModules();
64
+ : await planRuntimeSandboxModules({ excludedPorts: configuredGatewayPorts(options.env ?? process.env) });
65
65
  const bootstrap = await bootstrapLocalRuntime({
66
66
  projectId: token.projectId,
67
67
  planId: setupPlan.id,
@@ -273,6 +273,13 @@ export async function runOnboard(options) {
273
273
  throw new Error(`Witnora Setup Autopilot rolled back this install attempt: ${diagnosis}`);
274
274
  }
275
275
  }
276
+ function configuredGatewayPorts(environment) {
277
+ const value = environment.WITNORA_GATEWAY_PORT?.trim();
278
+ if (!value)
279
+ return new Set();
280
+ const port = Number(value);
281
+ return Number.isInteger(port) && port > 0 && port <= 65_535 ? new Set([port]) : new Set();
282
+ }
276
283
  async function inspectGatewayBinding(directory, projectId, server) {
277
284
  let value;
278
285
  try {
@@ -10,14 +10,20 @@ const MAX_AUDIT_BYTES = 10 * 1024 * 1024;
10
10
  const MAX_RESOURCES = 1_000;
11
11
  const RESOURCE = /^\/mock-state\/([A-Za-z0-9._:-]{1,128})$/;
12
12
  const AUDIT = /^\/audit\/actions\/([A-Za-z0-9._:-]{1,256})\/sessions\/([A-Za-z0-9._:-]{1,256})$/;
13
- export async function findAvailableRuntimeSandboxOrigin() {
14
- const server = createServer();
15
- await listen(server, 0);
16
- const address = server.address();
17
- if (!address || typeof address === "string")
18
- throw new Error("Could not allocate a localhost sandbox port.");
19
- await close(server);
20
- return `http://127.0.0.1:${address.port}`;
13
+ export async function findAvailableRuntimeSandboxOrigin(excludedPorts = new Set()) {
14
+ for (let attempt = 0; attempt < 20; attempt += 1) {
15
+ const server = createServer();
16
+ await listen(server, 0);
17
+ const address = server.address();
18
+ if (!address || typeof address === "string") {
19
+ await close(server);
20
+ throw new Error("Could not allocate a localhost sandbox port.");
21
+ }
22
+ await close(server);
23
+ if (!excludedPorts.has(address.port))
24
+ return `http://127.0.0.1:${address.port}`;
25
+ }
26
+ throw new Error("Could not allocate a localhost sandbox port distinct from the customer Gateway.");
21
27
  }
22
28
  export async function startRuntimeSandboxFixture(input) {
23
29
  const origin = exactOrigin(input.origin);
@@ -90,8 +90,8 @@ export async function saveRuntimeReferenceManifest(path, projectId, server, refe
90
90
  await rename(temporary, path);
91
91
  await chmod(path, 0o600).catch(() => undefined);
92
92
  }
93
- export async function planRuntimeSandboxModules() {
94
- const sandboxOrigin = await findAvailableRuntimeSandboxOrigin();
93
+ export async function planRuntimeSandboxModules(options = {}) {
94
+ const sandboxOrigin = await findAvailableRuntimeSandboxOrigin(options.excludedPorts);
95
95
  const generated = generateRuntimeSandboxKit(sandboxOrigin);
96
96
  return {
97
97
  sandboxOrigin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "witnora",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "description": "Independent assurance for covered agent action paths across models and frameworks.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",