{"version":3,"file":"runtime-harness.d.ts","sourceRoot":"","sources":["../../../src/core/executor-registry/runtime-harness.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,KAAK,EACX,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EACpB,MAAM,8BAA8B,CAAC;AAEtC,gFAAgF;AAChF,MAAM,WAAW,oBAAoB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,2BAA2B,IAAI,oBAAoB,CASlE;AAED,qEAAqE;AACrE,wBAAgB,uBAAuB,CAAC,GAAG,GAAE,MAAmB,GAAG,wBAAwB,CAQ1F;AAED,MAAM,WAAW,kCAAkC;IAClD,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,2BAA2B;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAClD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAS;IACpC,OAAO,CAAC,MAAM,CAAC,CAAuB;IAEtC,YAAY,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,kCAAuC,EAIhH;IAED,IAAI,KAAK,IAAI,oBAAoB,GAAG,SAAS,CAE5C;IAED,IAAI,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAE1C;IAED,IAAI,YAAY,IAAI,MAAM,GAAG,SAAS,CAErC;IAEK,QAAQ,CACb,KAAK,GAAE,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAC,GAAG;QAAE,sBAAsB,CAAC,EAAE,oBAAoB,CAAA;KAAO,GAC9G,OAAO,CAAC,yBAAyB,CAAC,CAUpC;IAEK,SAAS,CACd,KAAK,GAAE;QAAE,SAAS,CAAC,EAAE,wBAAwB,CAAC;QAAC,sBAAsB,CAAC,EAAE,oBAAoB,CAAA;KAAO,GACjG,OAAO,CAAC,wBAAwB,CAAC,CAMnC;IAEK,kBAAkB,CAAC,YAAY,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,CAEpF;IAEK,UAAU,IAAI,OAAO,CAAC,yBAAyB,CAAC,CAErD;IAED,OAAO,CAAC,aAAa;CAMrB","sourcesContent":["/**\n * Executor Runtime Registration (2.10.0).\n *\n * Minimal production-worthy helper that proves the runtime lifecycle\n * (activate / heartbeat / deactivate) without implementing the full worker\n * daemon. It collects only lightweight, safe local metadata and resource\n * observations; it never polls missions and never reserves resources.\n */\n\nimport * as os from \"node:os\";\nimport { VERSION } from \"../../config.js\";\nimport type { ExecutorControlService } from \"./executor-control-service.js\";\nimport type {\n\tActivateExecutorInput,\n\tExecutorActivationOutcome,\n\tExecutorCapabilities,\n\tExecutorDeactivateOutcome,\n\tExecutorHeartbeatOutcome,\n\tExecutorRecord,\n\tExecutorResourceSnapshot,\n\tExecutorRuntimeProof,\n} from \"./executor-registry-types.js\";\n\n/** Diagnostics-only local runtime metadata. Identity is `runtimeInstanceId`. */\nexport interface LocalRuntimeMetadata {\n\thostname: string;\n\tpid: number;\n\tplatform: string;\n\tarch: string;\n\tprocessStartedAtMs: number;\n\tjensenVersion: string;\n}\n\nexport function collectLocalRuntimeMetadata(): LocalRuntimeMetadata {\n\treturn {\n\t\thostname: os.hostname(),\n\t\tpid: process.pid,\n\t\tplatform: process.platform,\n\t\tarch: process.arch,\n\t\tprocessStartedAtMs: Date.now() - Math.floor(process.uptime() * 1000),\n\t\tjensenVersion: VERSION,\n\t};\n}\n\n/** Lightweight, non-authoritative resource observation at time T. */\nexport function collectResourceSnapshot(now: number = Date.now()): ExecutorResourceSnapshot {\n\treturn {\n\t\tobservedAtMs: now,\n\t\tcpuLogicalCount: os.cpus().length,\n\t\tmemoryTotalBytes: os.totalmem(),\n\t\tmemoryFreeBytes: os.freemem(),\n\t\tgpu: { status: \"unavailable\", devices: [] },\n\t};\n}\n\nexport interface ExecutorRuntimeRegistrationOptions {\n\t/** Expiry window for each heartbeat (default from service). */\n\texpiryMs?: number;\n}\n\nexport class ExecutorRuntimeRegistration {\n\tprivate readonly _service: ExecutorControlService;\n\tprivate readonly _executorId: string;\n\tprivate readonly _expiryMs?: number;\n\tprivate _proof?: ExecutorRuntimeProof;\n\n\tconstructor(service: ExecutorControlService, executorId: string, options: ExecutorRuntimeRegistrationOptions = {}) {\n\t\tthis._service = service;\n\t\tthis._executorId = executorId;\n\t\tthis._expiryMs = options.expiryMs;\n\t}\n\n\tget proof(): ExecutorRuntimeProof | undefined {\n\t\treturn this._proof;\n\t}\n\n\tget runtimeInstanceId(): string | undefined {\n\t\treturn this._proof?.runtimeInstanceId;\n\t}\n\n\tget runtimeEpoch(): number | undefined {\n\t\treturn this._proof?.runtimeEpoch;\n\t}\n\n\tasync activate(\n\t\tinput: Partial<Omit<ActivateExecutorInput, \"expiryMs\">> & { advertisedCapabilities?: ExecutorCapabilities } = {},\n\t): Promise<ExecutorActivationOutcome> {\n\t\tconst metadata = collectLocalRuntimeMetadata();\n\t\tconst outcome = await this._service.activateExecutor(this._executorId, {\n\t\t\t...metadata,\n\t\t\tresources: input.resources ?? collectResourceSnapshot(),\n\t\t\texpiryMs: this._expiryMs,\n\t\t\t...input,\n\t\t});\n\t\tthis._proof = outcome.proof;\n\t\treturn outcome;\n\t}\n\n\tasync heartbeat(\n\t\tinput: { resources?: ExecutorResourceSnapshot; advertisedCapabilities?: ExecutorCapabilities } = {},\n\t): Promise<ExecutorHeartbeatOutcome> {\n\t\treturn this._service.heartbeatExecutor(this._requireProof(), {\n\t\t\tresources: input.resources ?? collectResourceSnapshot(),\n\t\t\tadvertisedCapabilities: input.advertisedCapabilities,\n\t\t\texpiryMs: this._expiryMs,\n\t\t});\n\t}\n\n\tasync updateCapabilities(capabilities: ExecutorCapabilities): Promise<ExecutorRecord> {\n\t\treturn this._service.updateRuntimeCapabilities(this._requireProof(), capabilities);\n\t}\n\n\tasync deactivate(): Promise<ExecutorDeactivateOutcome> {\n\t\treturn this._service.deactivateExecutor(this._requireProof());\n\t}\n\n\tprivate _requireProof(): ExecutorRuntimeProof {\n\t\tif (!this._proof) {\n\t\t\tthrow new Error(`Executor runtime ${this._executorId} has not been activated`);\n\t\t}\n\t\treturn this._proof;\n\t}\n}\n"]}