Eval API

GetCalcMaster exposes a small, stable JSON API for deterministic evaluation (REAL / COMPLEX / TYPED / SYMBOLIC), plus an optional session + SSE layer for notebook-like workloads (cache, cancellation, streaming steps).

Endpoints

POST /api/eval
POST /api/eval/complex
POST /api/eval/batch
GET  /api/eval/capabilities

# Session/SSE (ephemeral cache + streaming)
POST   /api/eval/session
DELETE /api/eval/session/{sessionId}
GET    /api/eval/session/{sessionId}/stats
POST   /api/eval/session/{sessionId}/eval
POST   /api/eval/session/{sessionId}/eval/start
GET    /api/eval/session/{sessionId}/eval/stream/{requestId}   # text/event-stream (SSE)
POST   /api/eval/session/{sessionId}/eval/cancel/{requestId}

Request body (EvalRequestDto)

{
  "expression": "x^2 = 16",
  "vars": { "y": 3 },
  "angleMode": "RAD",
  "exact": false,

  "complex": false,
  "complexFormat": "rect",

  "mode": "AUTO",

  "functionCommaGrouping": false,

  "cellId": "optional-notebook-id",
  "executionIndex": 12
}
  • vars are numeric substitutions (finite doubles only; NaN/Infinity are sanitized).
  • mode is an optional routing hint (the engine may still auto-route).
  • functionCommaGrouping is the “Args: ;” policy toggle: when enabled, semicolons (;) separate function arguments and commas inside functions may be treated as thousands separators when well-formed.
  • cellId / executionIndex are optional notebook metadata.

Response body (EvalResponseDto)

The response always echoes input and may include normalizedInput, steps, and engine metadata.

{
  "input": "2 + 2",
  "normalizedInput": "2 + 2",
  "resultNumber": 4,
  "resultText": "4",
  "steps": [
    { "title": "Normalize", "detail": "2 + 2" },
    { "title": "Eval", "detail": "4" }
  ],
  "error": null,

  "isComplex": false,
  "isExact": true,

  "typedKind": null,
  "typedText": null,

  "mode": "REAL",
  "engineVersion": "simple-v11.5",
  "diagnostics": []
}

Notes: resultNumber is meaningful for REAL outputs. Complex responses populate complexRe, complexIm, etc. Typed responses set typedKind/typedText.

Error response

{
  "input": "1/0",
  "error": "Division by zero"
}

Capabilities

GET /api/eval/capabilities

Capabilities includes a function list and versioning: version is the kernel version; appVersion is the web app shell version.

Batch

POST /api/eval/batch
[
  { "expression": "2+2" },
  { "expression": "normalcdf(0)" }
]

Eval sessions (SSE)

  1. Create a session:
    POST /api/eval/session
    { "ttlSeconds": 1800 }
  2. Start an eval:
    POST /api/eval/session/{sessionId}/eval/start
    { "expression": "sqrt(2)", "exact": false }
  3. If cacheHit=false, stream:
    GET /api/eval/session/{sessionId}/eval/stream/{requestId}
    Accept: text/event-stream

SSE event types include: status, progress, step, done, error, ping.