Evaluate a typed decision
Use Jev or a compatible Laya server for typed choices, scores and yes/no probabilities.
Declare the questions
Section titled “Declare the questions”defineDecision() validates and freezes questions. A choice selects a named option, a score evaluates ordered levels, and noul returns the probability of yes. This declaration preserves the answer keys and choice literals in TypeScript.
The score levels are indexed from 0 to the number of levels minus one. The returned distributions, confidence values and yes/no probability come from the service; Outpost validates them without recomputing them. Optional noul.criteria describes the true and false outcomes.
Services such as Laya round probabilities and scores to four decimals. Validation allows the accumulated rounding error when checking distribution totals and weighted scores, while preserving every native value without renormalizing it. Incoherent totals and scores remain errors.
Connect Jev or Laya
Section titled “Connect Jev or Laya”One provider implements the System One protocol. Its base URL includes /v1; Outpost appends /systemone. The address and credentials are used by your Node.js process, independently of the sandbox.
Set the endpoint and a nonempty key for an authenticated service. apiKey: false explicitly selects an endpoint without authentication, such as your local Laya server. Providers do not read credentials automatically. See the Jev API and Laya server for server setup.
Evaluate the current state
Section titled “Evaluate the current state”Pass text, an object or an array containing lossless JSON. Cycles, dates, undefined properties, sparse arrays, nonfinite numbers and serialization hooks are rejected before sending a request.
Run node evaluate.ts with the service available. The result includes the provider, actual response model, normalized usage and available metadata. The HTTP provider retains the native JSON response in metadata, including Laya routing and input diagnostics. Decision models are names; generation and reasoning settings belong to conversational models.
Handle incomplete input and failures
Section titled “Handle incomplete input and failures”A reported truncation rejects with code response and details.truncated: true. Set allowTruncated: true only when your application accepts evaluating partial input. An absent truncated field does not prove that the service processed the complete input.
Requests have no internal retries. HTTP 429 is quota; timeouts are timeout; connection failures and unavailable HTTP statuses carry an availability classification. Invalid JSON, answers or usage fail with response. Caller cancellation propagates. The defaults are a 120-second timeout and an 8 MiB response limit.
Add a workflow task
Section titled “Add a workflow task”defineDecisionTask() uses the existing dependency, condition, retry, timeout and cache machinery. It evaluates its state callback with TaskContext and allocates no sandbox. Dependent tasks receive typed answers through context.value(triage).
Include both tasks in a workflow. Completed checkpoints restore the result without another evaluation; an interrupted attempt still needs explicit replay authorization. Cache keys and versions must cover the state and decision configuration: questions, endpoint, model and truncation policy. Cache hits use no attempts or tokens.
Decision usage enters workflow budgets synchronously, including valid usage received with a result later rejected for truncation. Missing usage remains incomplete, so strict token budgets cannot assume zero consumption. See budgets, task caches and model routing.
Exercise the contract offline
Section titled “Exercise the contract offline”This explicit test provider returns a fixed answer and usage receipt. Run node offline.ts to exercise declaration, validation and result handling without a model account. This checks the Outpost contract; it does not validate real Jev or Laya inference.
API: defineDecision · decide · defineDecisionTask · DecisionProvider.