Signal · guide

A decision

Questions with fixed options about something, and an answer to each. On a decision model each answer comes with its probability.

Install it
pnpm add @niscorp/signal zod
Step 1 of 3

A decision model

typesafe is a provider of another kind: its model writes no text. It reads a state and questions, and returns a probability for each option. It needs no SDK.

A decision model
import { createSignal } from '@niscorp/signal';

const decider = createSignal('typesafe');
Step 2 of 3

The questions

A choice has options, each with a sentence saying when it applies. A noul is a yes or no, answered as the probability of yes. A score is a level on a scale you describe.

The questions are the schema: an answer that names an option you did not give fails the call.

The questions
const questions = {
  wants: {
    type: 'choice',
    instructions: 'What does the member want?',
    criteria: { seats: 'Seats for a night', refund: 'Money back', other: 'Anything else' },
  },
  urgent: { type: 'noul', instructions: 'Does it need an answer today?' },
} as const;
Step 3 of 3

The decision

state is what the questions are about: a string, an object or a list. Each answer is typed from its question, so wants.choice is one of your three options.

calibrated says whether the numbers are there. A chat provider can answer the same call, and then it is false and you get the choices alone.

The decision
const result = await decider.decide({ state: 'Two for The Tempest on Saturday, please.', questions });

console.log(result.decisions.wants.choice, result.decisions.urgent.answer);
if (result.calibrated) {
  console.log(result.decisions.wants.probabilities, result.decisions.urgent.noul);
}
Then

Run it.

This file asks a decision model, so it is not run on this site. It prints the choice and the yes or no, for instance seats false, and then the probability of each option and of yes.

Run it
TYPESAFE_API_KEY=your-key npx tsx decide.mts