von-sdk 1.0.1 → 1.1.1

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/dist/client.d.ts CHANGED
@@ -1,4 +1,10 @@
1
1
  import type { ChoiceAnswer, Question, ScoreAnswer, SystemOneResponse, VonClientOptions } from "./types.js";
2
+ /**
3
+ * The model version this SDK targets. Von ships exactly one model and the
4
+ * server always stamps responses with the version it actually served, so this
5
+ * is a request hint rather than a selector.
6
+ */
7
+ export declare const VON_MODEL = "von-1.1.0";
2
8
  export declare class VonError extends Error {
3
9
  status?: number;
4
10
  details?: unknown;
package/dist/index.js CHANGED
@@ -22,6 +22,8 @@ function score(instructions, criteria) {
22
22
  };
23
23
  }
24
24
  // src/client.ts
25
+ var VON_MODEL = "von-1.1.0";
26
+
25
27
  class VonError extends Error {
26
28
  status;
27
29
  details;
@@ -47,7 +49,7 @@ class VonClient {
47
49
  async systemOne({
48
50
  state,
49
51
  questions,
50
- model = "von-1.0.0"
52
+ model = VON_MODEL
51
53
  }) {
52
54
  const url = `${this.baseURL}/v1/systemone`;
53
55
  const headers = {
@@ -86,7 +88,7 @@ class VonClient {
86
88
  clearTimeout(timer);
87
89
  }
88
90
  }
89
- async decide(state, choices, instructions = "Which option best describes the state?", model = "von-1.0.0") {
91
+ async decide(state, choices, instructions = "Which option best describes the state?", model = VON_MODEL) {
90
92
  const q = choice(instructions, choices);
91
93
  const resp = await this.systemOne({
92
94
  state,
@@ -95,7 +97,7 @@ class VonClient {
95
97
  });
96
98
  return resp.answers["decision"];
97
99
  }
98
- async judge(state, instructions, posCriteria, negCriteria, model = "von-1.0.0") {
100
+ async judge(state, instructions, posCriteria, negCriteria, model = VON_MODEL) {
99
101
  const criteria = posCriteria || negCriteria ? { pos: posCriteria, neg: negCriteria } : undefined;
100
102
  const q = noul(instructions, criteria);
101
103
  const resp = await this.systemOne({
@@ -105,7 +107,7 @@ class VonClient {
105
107
  });
106
108
  return resp.answers["verdict"].noul;
107
109
  }
108
- async rate(state, levels, instructions = "Rate the severity or level:", model = "von-1.0.0") {
110
+ async rate(state, levels, instructions = "Rate the severity or level:", model = VON_MODEL) {
109
111
  const q = score(instructions, levels);
110
112
  const resp = await this.systemOne({
111
113
  state,
@@ -118,6 +120,7 @@ class VonClient {
118
120
  var TypeSafeClient = VonClient;
119
121
  export {
120
122
  TypeSafeClient,
123
+ VON_MODEL,
121
124
  VonClient,
122
125
  VonError,
123
126
  choice,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "von-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "description": "Official TypeScript/JavaScript SDK for Von - The Open-Source System One Decision Model",
5
5
  "author": "Victor Hugo <victor.panisa@gmail.com>",
6
6
  "license": "Apache-2.0",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",
19
- "url": "https://github.com/wfzyx/von.git",
19
+ "url": "git+https://github.com/wfzyx/von.git",
20
20
  "directory": "js"
21
21
  },
22
22
  "homepage": "https://github.com/wfzyx/von#readme",
@@ -42,5 +42,8 @@
42
42
  "devDependencies": {
43
43
  "@types/node": "^26.6.2",
44
44
  "typescript": "^7.0.2"
45
+ },
46
+ "bugs": {
47
+ "url": "https://github.com/wfzyx/von/issues"
45
48
  }
46
49
  }
@@ -1,34 +0,0 @@
1
- import type { ChoiceAnswer, Question, ScoreAnswer, SystemOneResponse, VonClientOptions } from "./types.js";
2
- export declare class VonError extends Error {
3
- status?: number;
4
- details?: unknown;
5
- constructor(message: string, status?: number, details?: unknown);
6
- }
7
- export declare class VonClient {
8
- baseURL: string;
9
- apiKey?: string;
10
- timeout: number;
11
- constructor(options?: VonClientOptions);
12
- /**
13
- * Evaluates state and questions via System One wire protocol (POST /v1/systemone).
14
- */
15
- systemOne({ state, questions, model, }: {
16
- state: unknown;
17
- questions: Record<string, Question>;
18
- model?: string;
19
- }): Promise<SystemOneResponse>;
20
- /**
21
- * Convenience helper for discrete categorical choice classification.
22
- */
23
- decide(state: unknown, choices: Record<string, string | null> | string[], instructions?: string, model?: string): Promise<ChoiceAnswer>;
24
- /**
25
- * Convenience helper for binary verification (Noul probability).
26
- */
27
- judge(state: unknown, instructions: string, posCriteria?: string, negCriteria?: string, model?: string): Promise<number>;
28
- /**
29
- * Convenience helper for ordinal multi-level rating (Score).
30
- */
31
- rate(state: unknown, levels: string[] | Record<string, string>, instructions?: string, model?: string): Promise<ScoreAnswer>;
32
- }
33
- /** Drop-in alias for TypeSafe Jev SDK migration */
34
- export declare const TypeSafeClient: typeof VonClient;
@@ -1,3 +0,0 @@
1
- export * from "./types.js";
2
- export * from "./primitives.js";
3
- export * from "./client.js";
@@ -1,16 +0,0 @@
1
- import type { ChoiceQuestion, NoulQuestion, ScoreQuestion } from "./types.js";
2
- /**
3
- * Build a discrete categorical Choice question.
4
- */
5
- export declare function choice(instructions: string, criteria: Record<string, string | null> | string[]): ChoiceQuestion;
6
- /**
7
- * Build a binary verification Noul (Yes/No probability) question.
8
- */
9
- export declare function noul(instructions: string, criteria?: {
10
- pos?: string;
11
- neg?: string;
12
- } | null): NoulQuestion;
13
- /**
14
- * Build an ordinal multi-level Score question.
15
- */
16
- export declare function score(instructions: string, criteria: string[] | Record<string, string>): ScoreQuestion;
@@ -1,56 +0,0 @@
1
- /**
2
- * Core type definitions for Von System One decisions.
3
- */
4
- export type QuestionType = "noul" | "choice" | "score";
5
- export interface BaseQuestion {
6
- type: QuestionType;
7
- instructions: string;
8
- }
9
- export interface NoulQuestion extends BaseQuestion {
10
- type: "noul";
11
- criteria?: {
12
- pos?: string;
13
- neg?: string;
14
- } | null;
15
- }
16
- export interface ChoiceQuestion extends BaseQuestion {
17
- type: "choice";
18
- criteria: Record<string, string | null>;
19
- }
20
- export interface ScoreQuestion extends BaseQuestion {
21
- type: "score";
22
- criteria: string[] | Record<string, string>;
23
- }
24
- export type Question = NoulQuestion | ChoiceQuestion | ScoreQuestion;
25
- export interface NoulAnswer {
26
- type: "noul";
27
- noul: number;
28
- }
29
- export interface ChoiceAnswer {
30
- type: "choice";
31
- choice: string;
32
- probabilities: Record<string, number>;
33
- confidence: number;
34
- }
35
- export interface ScoreAnswer {
36
- type: "score";
37
- score: number;
38
- confidence: number;
39
- legend: Record<string, string>;
40
- probabilities: Record<string, number>;
41
- }
42
- export type Answer = NoulAnswer | ChoiceAnswer | ScoreAnswer;
43
- export interface Usage {
44
- input_tokens: number;
45
- output_tokens: number;
46
- }
47
- export interface SystemOneResponse {
48
- model: string;
49
- answers: Record<string, Answer>;
50
- usage: Usage;
51
- }
52
- export interface VonClientOptions {
53
- baseURL?: string;
54
- apiKey?: string;
55
- timeout?: number;
56
- }