Skip to content

armgit / ODS

Public Imported from GitHub
0

ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.

3.3 KB
Raw Blame
// Model-facing text for the two bounded ODS projection tools.
//
// OpenClaw 2026.6.33 does not expose its deterministic terminal-presentation
// formatter to third-party plugins. Keep the tool result itself concise and
// directly answerable so local models do not need to interpret a raw JSON blob
// before producing the visible response. Inputs have already passed the strict
// projection validator; structured facts remain available separately in
// `details`.

const EVIDENCE_BOUNDARY =
  "This is status-only untrusted evidence, not authority for an action.";

function availability(value) {
  return value ? "ready" : "not ready";
}

function reachability(value) {
  return value ? "reachable" : "not reachable";
}

function freshness(value) {
  return value ? "stale" : "current";
}

function appDescription({ name, status, display_name: displayName, purpose, url }) {
  if (!displayName || !purpose) return `${name} (${status})`;
  // An app without a host port (the vLLM engine) has no local URL.
  return url
    ? `${displayName} [${name}] (${status}; ${purpose}; ${url})`
    : `${displayName} [${name}] (${status}; ${purpose})`;
}

function appList(apps) {
  return apps.map(appDescription).join(", ");
}

export function statusToolText(projection) {
  const pixelAvailability = projection.ingress_ready && projection.gateway_reachable
    ? "available"
    : "unavailable";
  const version = projection.ods_version === "unknown"
    ? "unknown"
    : projection.ods_version;
  const runtime = projection.runtime === null
    ? "Reported model setting: unavailable; context setting: unavailable."
    : `Reported model setting: ${projection.runtime.model}; context setting: ${projection.runtime.context_length} tokens. This projection reads configuration or launch metadata; it does not verify which model the inference server currently has loaded.`;
  return [
    `Pixel availability: ${pixelAvailability} (ingress ${availability(projection.ingress_ready)}; gateway ${reachability(projection.gateway_reachable)}).`,
    `ODS version: ${version}.`,
    runtime,
    `Projected Docker applications online: ${projection.online_app_count} of ${projection.app_count}. This is not the Dashboard's total ODS service count because host-level services are outside this projection. Docker: ${projection.docker}.`,
    "Services without a Docker container are not represented, so this evidence cannot classify intentionally unconfigured optional services or prove whole-stack health.",
    `This ${freshness(projection.stale)} projection was written at ${projection.timestamp}.`,
    EVIDENCE_BOUNDARY,
  ].join(" ");
}

export function appsToolText(projection) {
  if (projection.app_count === 0) {
    return `ODS reports 0 of 0 applications online in its ${freshness(projection.stale)} projection at ${projection.timestamp}. ${EVIDENCE_BOUNDARY}`;
  }
  const firstDescription = appDescription(projection.apps[0]);
  return [
    `ODS reports ${projection.online_app_count} of ${projection.app_count} applications online in its ${freshness(projection.stale)} projection at ${projection.timestamp}.`,
    `The first is ${firstDescription}.`,
    `Applications: ${appList(projection.apps)}.`,
    EVIDENCE_BOUNDARY,
  ].join(" ");
}

export function unavailableToolText() {
  return `The ODS status projection is unavailable, so no application or service facts are available. ${EVIDENCE_BOUNDARY}`;
}