witnora 0.20.4 → 0.20.6

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/cli.js CHANGED
@@ -41,7 +41,7 @@ import { inspectRepository } from "./onboard.js";
41
41
  import { renderReleaseEvaluation, runReleaseEvaluation } from "./release-evaluation.js";
42
42
  import { runPrivateCapabilityDiscovery } from "./private-discovery.js";
43
43
  import { configureManagedWorkflowHarness, doctorCustomerGateway, initializeCustomerGateway, isGatewayDoctorReady, readManagedCustomerGatewayLogs, renderGatewayDoctor, renderManagedGatewayStatus, restartManagedCustomerGateway, runCustomerGateway, startManagedCustomerGateway, statusManagedCustomerGateway, stopManagedCustomerGateway, superviseManagedCustomerGateway, } from "./gateway.js";
44
- import { installCurrentGatewayService, uninstallCurrentGatewayService } from "./gateway-service.js";
44
+ import { installCurrentGatewayService, stopCurrentGatewayOwners, uninstallCurrentGatewayService } from "./gateway-service.js";
45
45
  import { verifyEvidencePacketV02 } from "./evidence-v02.js";
46
46
  process.on("uncaughtException", reportFatalError);
47
47
  process.on("unhandledRejection", reportFatalError);
@@ -265,7 +265,15 @@ else if (command === "gateway") {
265
265
  await superviseManagedCustomerGateway({ repository: readFlag("--repo") ?? process.cwd(), dir: readFlag("--dir"), configHome: readFlag("--config-home"), serviceLeasePath: readFlag("--service-lease"), serviceGeneration: readFlag("--service-generation"), output: (message) => process.stdout.write(message) });
266
266
  }
267
267
  else if (action === "stop") {
268
- const result = await stopManagedCustomerGateway({ repository: readFlag("--repo") ?? process.cwd(), dir: readFlag("--dir") });
268
+ const repository = readFlag("--repo") ?? process.cwd();
269
+ const dir = readFlag("--dir");
270
+ const configHome = readFlag("--config-home");
271
+ const result = await stopCurrentGatewayOwners({
272
+ repository,
273
+ gatewayDirectory: dir,
274
+ cliEntry: fileURLToPath(import.meta.url),
275
+ configHome,
276
+ }, () => stopManagedCustomerGateway({ repository, dir, configHome }));
269
277
  process.stdout.write(readBoolFlag("--json") ? `${JSON.stringify(result, null, 2)}\n` : renderManagedGatewayStatus(result));
270
278
  }
271
279
  else if (action === "run") {
@@ -78,6 +78,13 @@ export async function stopCurrentGatewayService(options) {
78
78
  }
79
79
  return plan;
80
80
  }
81
+ export async function stopCurrentGatewayOwners(options, stopManagedGateway) {
82
+ await stopCurrentGatewayService(options);
83
+ const result = await stopManagedGateway();
84
+ if (result.healthy)
85
+ throw new Error("The customer-owned Gateway remained healthy after its operating-system supervisor was stopped.");
86
+ return result.stopped ? result : { ...result, stopped: true };
87
+ }
81
88
  export function createGatewayServicePlan(input) {
82
89
  const suffix = createHash("sha256").update(`${input.repository}\n${input.gatewayDirectory}`).digest("hex").slice(0, 12);
83
90
  const id = `witnora-gateway-${suffix}`;
package/dist/gateway.js CHANGED
@@ -576,6 +576,10 @@ export async function runCustomerGateway(options) {
576
576
  FileActionCheckpointStore: (await durableWorker).FileActionCheckpointStore,
577
577
  })
578
578
  : undefined;
579
+ const probeCredentialReady = createBoundedRuntimeProbeReadiness({
580
+ check: () => runtimeProbeCredentialReady(config, options.configHome),
581
+ initialReady: true,
582
+ });
579
583
  const assuranceController = await createContinuousAssuranceController({
580
584
  repository: resolve(directory, "..", ".."), directory, projectId: config.projectId, server: config.server,
581
585
  apiKey: connection.apiKey, config, sourceSigner: () => keyRing.activeSigner(),
@@ -598,7 +602,7 @@ export async function runCustomerGateway(options) {
598
602
  track: (input) => isConfiguredRuntimeProposal(input.proposal, config.runtimeWorker) ? actionWorker.track(input) : Promise.resolve(undefined),
599
603
  status: async () => {
600
604
  const status = await actionWorker.status();
601
- const probeReady = await runtimeProbeCredentialReady(config, options.configHome);
605
+ const probeReady = await probeCredentialReady();
602
606
  return {
603
607
  ...status,
604
608
  ready: status.ready === true && probeReady,
@@ -2221,6 +2225,34 @@ function wait(milliseconds) {
2221
2225
  function safeSlug(value) {
2222
2226
  return (value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "agent-repository").slice(0, 48);
2223
2227
  }
2228
+ export function createBoundedRuntimeProbeReadiness(input) {
2229
+ const now = input.now ?? Date.now;
2230
+ const successTtlMs = input.successTtlMs ?? 300_000;
2231
+ const failureTtlMs = input.failureTtlMs ?? 15_000;
2232
+ let ready = input.initialReady ?? false;
2233
+ let checkedAt = input.initialReady === undefined ? Number.NEGATIVE_INFINITY : now();
2234
+ let pending;
2235
+ return async () => {
2236
+ const ttl = ready ? successTtlMs : failureTtlMs;
2237
+ if (now() - checkedAt < ttl)
2238
+ return ready;
2239
+ if (pending)
2240
+ return pending;
2241
+ pending = input.check()
2242
+ .then((nextReady) => {
2243
+ ready = nextReady;
2244
+ checkedAt = now();
2245
+ return ready;
2246
+ })
2247
+ .catch(() => {
2248
+ ready = false;
2249
+ checkedAt = now();
2250
+ return false;
2251
+ })
2252
+ .finally(() => { pending = undefined; });
2253
+ return pending;
2254
+ };
2255
+ }
2224
2256
  function collectorIdForRepository(repository, projectId) {
2225
2257
  const readable = safeSlug(basename(repository)).slice(0, 36);
2226
2258
  const identity = createHash("sha256").update(`${resolve(repository)}\n${projectId}`).digest("hex").slice(0, 10);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "witnora",
3
- "version": "0.20.4",
3
+ "version": "0.20.6",
4
4
  "description": "Independent assurance for covered agent action paths across models and frameworks.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",