{"version":3,"file":"admission-protocol.d.ts","sourceRoot":"","sources":["../../../src/core/shared-inference/admission-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACX,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EACjB,0BAA0B,EAC1B,uBAAuB,EACvB,qBAAqB,EACrB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,0BAA0B,GAAa,CAAC;AAErD,MAAM,MAAM,sBAAsB,GAAG;IAAE,MAAM,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAA;CAAE,CAAC;AAMnH,MAAM,WAAW,uBAAuB;IACvC,eAAe,EAAE,OAAO,0BAA0B,CAAC;IACnD,+EAA+E;IAC/E,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,mFAAmF;IACnF,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,UAAU,CAAC,EAAE,0BAA0B,CAAC;IACxC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACpC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB;IACvC,eAAe,EAAE,OAAO,0BAA0B,CAAC;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,OAAO,EAAE;QACR,KAAK,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,aAAa,CAAC;QAC5D,KAAK,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gB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAgBxE","sourcesContent":["/**\n * Shared inference admission protocol (3.0.0 cross-host bridge).\n *\n * Structured HTTP + JSON protocol between a remote Jensen runtime and the local\n * admission service. The service owns the scheduler; the remote client only\n * asks (request/wait/renew/release/cancel). Protocol version is explicit and a\n * mismatch is a structural failure, never a silent reinterpretation.\n *\n * No credentials, prompts, or message bodies cross this protocol: only\n * correlation ids, scheduling metadata, and lease identities.\n */\n\nimport type {\n\tAdmittedInference,\n\tEnqueueInferenceOutcome,\n\tInferenceAdmissionStatus,\n\tInferencePriority,\n\tInferenceRequestDependency,\n\tReleaseInferenceOutcome,\n\tRenewInferenceOutcome,\n} from \"./types.js\";\n\nexport const ADMISSION_PROTOCOL_VERSION = 1 as const;\n\nexport type AdmissionCancelOutcome = { status: \"cancelled\" | \"not_found\" | \"running\"; inferenceRequestId: string };\n\n// =============================================================================\n// Request payloads (client -> service)\n// =============================================================================\n\nexport interface AdmissionRequestPayload {\n\tprotocolVersion: typeof ADMISSION_PROTOCOL_VERSION;\n\t/** Execution-scoped correlation (validated against the bearer token scope). */\n\texecutionId: string;\n\tlogicalAgentId: string;\n\t/** Resource identity is resolved CENTRALLY; the client never declares capacity. */\n\tprovider: string;\n\tmodel: string;\n\tinferenceRequestId?: string;\n\tmissionId?: string;\n\tassignmentId?: string;\n\tpriority?: InferencePriority;\n\tdependency?: InferenceRequestDependency;\n\testimatedInputTokens?: number;\n\tmaxOutputTokens?: number;\n}\n\nexport interface AdmissionStatusQuery {\n\tinferenceRequestId: string;\n\texecutionId: string;\n}\n\nexport interface AdmissionReleasePayload {\n\tprotocolVersion: typeof ADMISSION_PROTOCOL_VERSION;\n\texecutionId: string;\n\tadmitted: AdmittedInference;\n\toutcome: {\n\t\tstate: \"COMPLETED\" | \"FAILED\" | \"CANCELLED\" | \"INTERRUPTED\";\n\t\tusage?: { input?: number; output?: number };\n\t\terrorMessage?: string;\n\t};\n}\n\nexport interface AdmissionRenewPayload {\n\tprotocolVersion: typeof ADMISSION_PROTOCOL_VERSION;\n\texecutionId: string;\n\tadmitted: AdmittedInference;\n}\n\nexport interface AdmissionCancelPayload {\n\tprotocolVersion: typeof ADMISSION_PROTOCOL_VERSION;\n\texecutionId: string;\n\tinferenceRequestId: string;\n}\n\n// =============================================================================\n// Response envelopes (service -> client)\n// =============================================================================\n\nexport type AdmissionResponse =\n\t| { kind: \"request_result\"; outcome: EnqueueInferenceOutcome }\n\t| { kind: \"status_result\"; status: InferenceAdmissionStatus }\n\t| { kind: \"release_result\"; outcome: ReleaseInferenceOutcome }\n\t| { kind: \"renew_result\"; outcome: RenewInferenceOutcome }\n\t| { kind: \"cancel_result\"; outcome: AdmissionCancelOutcome }\n\t| { kind: \"error\"; code: AdmissionErrorCode; message: string };\n\nexport type AdmissionErrorCode =\n\t| \"UNAUTHORIZED\"\n\t| \"PROTOCOL_MISMATCH\"\n\t| \"RESOURCE_NOT_REGISTERED\"\n\t| \"MALFORMED_REQUEST\"\n\t| \"SCHEDULER_UNAVAILABLE\"\n\t| \"INTERNAL_ERROR\";\n\nexport class AdmissionProtocolError extends Error {\n\treadonly code: AdmissionErrorCode;\n\tconstructor(code: AdmissionErrorCode, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"AdmissionProtocolError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Validate an untrusted response envelope from the service. */\nexport function parseAdmissionResponse(value: unknown): AdmissionResponse {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n\t\tthrow new AdmissionProtocolError(\"MALFORMED_REQUEST\", \"response must be an object\");\n\t}\n\tconst doc = value as Record<string, unknown>;\n\tif (doc.kind === \"request_result\")\n\t\treturn { kind: \"request_result\", outcome: doc.outcome as EnqueueInferenceOutcome };\n\tif (doc.kind === \"status_result\") return { kind: \"status_result\", status: doc.status as InferenceAdmissionStatus };\n\tif (doc.kind === \"release_result\")\n\t\treturn { kind: \"release_result\", outcome: doc.outcome as ReleaseInferenceOutcome };\n\tif (doc.kind === \"renew_result\") return { kind: \"renew_result\", outcome: doc.outcome as RenewInferenceOutcome };\n\tif (doc.kind === \"cancel_result\") return { kind: \"cancel_result\", outcome: doc.outcome as AdmissionCancelOutcome };\n\tif (doc.kind === \"error\") {\n\t\treturn { kind: \"error\", code: doc.code as AdmissionErrorCode, message: String(doc.message ?? \"\") };\n\t}\n\tthrow new AdmissionProtocolError(\"PROTOCOL_MISMATCH\", `unknown response kind: ${String(doc.kind)}`);\n}\n"]}