mycomesh-consumer 0.1.33 → 0.1.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mycomesh-consumer",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
4
4
  "description": "Native Node.js MycoMesh Consumer and OpenAI-compatible request CLI.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -949,7 +949,7 @@ function writeJson(response, status, value, headers = {}) {
949
949
  response.end(body);
950
950
  }
951
951
 
952
- async function handleInference(state, request, response, path) {
952
+ async function handleInference(state, request, response, path, alphaSearchQuery) {
953
953
  const authorization = String(request.headers.authorization || "");
954
954
  if (!sameSecret(authorization, `Bearer ${state.paymentKey}`)) {
955
955
  writeJson(response, 401, openaiError("invalid MycoMesh payment key", "invalid_api_key"));
@@ -960,6 +960,15 @@ async function handleInference(state, request, response, path) {
960
960
  writeJson(response, 400, openaiError(error.message, "invalid_request_error"));
961
961
  return;
962
962
  }
963
+ const alphaSearch = alphaSearchQuery !== undefined;
964
+ if (alphaSearch) {
965
+ body = {
966
+ model: body.model,
967
+ input: [{ type: "mycomesh_alpha_search_request", request: body, query: alphaSearchQuery }],
968
+ max_output_tokens: body.max_output_tokens ?? 2000,
969
+ };
970
+ path = "/v1/responses";
971
+ }
963
972
  if (path.endsWith("/responses/compact") && !hasCompactionTrigger(body.input)) {
964
973
  const items = Array.isArray(body.input) ? [...body.input] : [];
965
974
  if (body.input !== undefined && body.input !== "" && !Array.isArray(body.input)) {
@@ -975,6 +984,15 @@ async function handleInference(state, request, response, path) {
975
984
  return;
976
985
  }
977
986
  for (const [name, value] of Object.entries(result.headers || {})) response.setHeader(name, value);
987
+ if (alphaSearch) {
988
+ const payload = result.payload?.mycomesh_alpha_search_response;
989
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
990
+ writeJson(response, 502, openaiError("Provider returned an invalid alpha/search response", "mycomesh_provider_error"));
991
+ return;
992
+ }
993
+ writeJson(response, 200, payload, result.headers);
994
+ return;
995
+ }
978
996
  if (body.stream === true) {
979
997
  response.writeHead(200, { "content-type": "text/event-stream; charset=utf-8", "cache-control": "no-cache", connection: "keep-alive", "x-mycomesh-streaming-mode": "buffered" });
980
998
  const events = path.endsWith("/chat/completions")
@@ -1039,6 +1057,9 @@ export function createConsumerServer(state, { host = "127.0.0.1", port = 8110 }
1039
1057
  : "/v1/responses";
1040
1058
  await handleInference(state, request, response, relayPath); return;
1041
1059
  }
1060
+ if (request.method === "POST" && ["/alpha/search", "/v1/alpha/search", "/backend-api/codex/alpha/search"].includes(path)) {
1061
+ await handleInference(state, request, response, "/v1/responses", Object.fromEntries(url.searchParams)); return;
1062
+ }
1042
1063
  writeJson(response, 404, openaiError("route not found", "invalid_request_error"));
1043
1064
  } catch (error) {
1044
1065
  if (!response.headersSent) writeJson(response, 500, openaiError(error.message)); else response.destroy();
package/src/consumer.mjs CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  createConsumerServer,
12
12
  } from "./consumer-runtime.mjs";
13
13
 
14
- export const CONSUMER_RELEASE_VERSION = "0.1.33";
14
+ export const CONSUMER_RELEASE_VERSION = "0.1.34";
15
15
  export const API_COMMANDS = new Set(["health", "models", "responses", "chat"]);
16
16
  const API_VALUE_OPTIONS = new Set([
17
17
  "--base-url",