@pal-code/jev 0.0.0-stage → 0.0.18

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/package.json CHANGED
@@ -1,6 +1,22 @@
1
1
  {
2
2
  "name": "@pal-code/jev",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.18",
4
+ "description": "Jev (System One) judgment extension for pal — typed, calibrated decisions over OpenCode Zen",
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "type": "module",
10
+ "exports": {
11
+ ".": "./src/index.ts"
12
+ },
13
+ "files": [
14
+ "src/**/*.ts"
15
+ ],
16
+ "dependencies": {
17
+ "@pal-code/core": "0.0.18"
18
+ },
19
+ "engines": {
20
+ "bun": ">=1.1.0"
21
+ }
22
+ }
@@ -0,0 +1,154 @@
1
+ import {afterEach, describe, expect, test} from 'bun:test';
2
+
3
+ import {askJev, JevError} from './client.js';
4
+ import type {JevSettings} from './config.js';
5
+
6
+ const realFetch = globalThis.fetch;
7
+
8
+ function settings(overrides: Partial<JevSettings> = {}): JevSettings {
9
+ return {
10
+ baseUrl: 'https://example.test/systemone',
11
+ model: 'jev-1.13-free',
12
+ apiKey: 'test-key',
13
+ keySource: 'env',
14
+ timeoutMs: 5000,
15
+ ...overrides,
16
+ };
17
+ }
18
+
19
+ afterEach(() => {
20
+ globalThis.fetch = realFetch;
21
+ });
22
+
23
+ function stubFetch(impl: (url: string, init: RequestInit) => Promise<Response>) {
24
+ const calls: Array<{url: string; init: RequestInit}> = [];
25
+ globalThis.fetch = (async (url: unknown, init: unknown) => {
26
+ calls.push({url: String(url), init: init as RequestInit});
27
+ return impl(String(url), init as RequestInit);
28
+ }) as typeof fetch;
29
+ return calls;
30
+ }
31
+
32
+ function jsonResponse(body: unknown, status = 200): Response {
33
+ return new Response(JSON.stringify(body), {
34
+ status,
35
+ headers: {'Content-Type': 'application/json'},
36
+ });
37
+ }
38
+
39
+ describe('askJev request', () => {
40
+ test('POSTs model, state and questions to exactly the configured URL', async () => {
41
+ const calls = stubFetch(async () =>
42
+ jsonResponse({model: 'jev-1.13-free', answers: {q: {type: 'noul', noul: 0.7}}}),
43
+ );
44
+
45
+ await askJev(settings(), 'some state', {q: {type: 'noul', instructions: 'is it?'}});
46
+
47
+ expect(calls).toHaveLength(1);
48
+ expect(calls[0].url).toBe('https://example.test/systemone');
49
+ expect(calls[0].init.method).toBe('POST');
50
+
51
+ const headers = calls[0].init.headers as Record<string, string>;
52
+ expect(headers.Authorization).toBe('Bearer test-key');
53
+
54
+ const body = JSON.parse(String(calls[0].init.body));
55
+ expect(body).toEqual({
56
+ model: 'jev-1.13-free',
57
+ state: 'some state',
58
+ questions: {q: {type: 'noul', instructions: 'is it?'}},
59
+ });
60
+ });
61
+
62
+ test('refuses to call out at all without a key', async () => {
63
+ const calls = stubFetch(async () => jsonResponse({answers: {}}));
64
+ await expect(
65
+ askJev(settings({apiKey: ''}), 's', {q: {type: 'noul', instructions: 'x'}}),
66
+ ).rejects.toBeInstanceOf(JevError);
67
+ expect(calls).toHaveLength(0);
68
+ });
69
+
70
+ test('a non-2xx becomes a fixed-string error that never echoes the body', async () => {
71
+ stubFetch(async () => new Response('secret-looking reflected content', {status: 401}));
72
+ let message = '';
73
+ try {
74
+ await askJev(settings(), 's', {q: {type: 'noul', instructions: 'x'}});
75
+ } catch (err) {
76
+ message = (err as Error).message;
77
+ }
78
+ expect(message).toContain('401');
79
+ expect(message).not.toContain('reflected');
80
+ });
81
+ });
82
+
83
+ describe('askJev response parsing', () => {
84
+ test('parses noul, choice and score answers with their distributions', async () => {
85
+ stubFetch(async () =>
86
+ jsonResponse({
87
+ model: 'jev-1.13-free',
88
+ answers: {
89
+ yes: {type: 'noul', noul: 0.96},
90
+ pick: {type: 'choice', choice: 'a', confidence: 0.99, probabilities: {a: 0.99, b: 0.01}},
91
+ rate: {type: 'score', score: 0.5, confidence: 0.8, legend: {0: 'low', 1: 'high'}},
92
+ },
93
+ usage: {input_tokens: 100, output_tokens: 10, cost: 0},
94
+ }),
95
+ );
96
+
97
+ const res = await askJev(settings(), 's', {q: {type: 'noul', instructions: 'x'}});
98
+ expect(res.answers.yes.noul).toBe(0.96);
99
+ expect(res.answers.pick.choice).toBe('a');
100
+ expect(res.answers.pick.probabilities).toEqual({a: 0.99, b: 0.01});
101
+ expect(res.answers.rate.legend).toEqual({0: 'low', 1: 'high'});
102
+ expect(res.usage).toEqual({inputTokens: 100, outputTokens: 10, cost: 0});
103
+ });
104
+
105
+ test('drops a malformed answer instead of surfacing a plausible number', async () => {
106
+ stubFetch(async () =>
107
+ jsonResponse({
108
+ answers: {
109
+ good: {type: 'noul', noul: 0.4},
110
+ noType: {noul: 0.9},
111
+ notAnObject: 'nope',
112
+ },
113
+ }),
114
+ );
115
+
116
+ const res = await askJev(settings(), 's', {q: {type: 'noul', instructions: 'x'}});
117
+ expect(Object.keys(res.answers)).toEqual(['good']);
118
+ });
119
+
120
+ test('a non-finite probability is dropped, not coerced', async () => {
121
+ stubFetch(async () => jsonResponse({answers: {q: {type: 'noul', noul: 'NaN'}}}));
122
+ const res = await askJev(settings(), 's', {q: {type: 'noul', instructions: 'x'}});
123
+ expect(res.answers.q.noul).toBeUndefined();
124
+ });
125
+
126
+ test('a body with no answers raises rather than reporting an empty success', async () => {
127
+ stubFetch(async () => jsonResponse({model: 'm'}));
128
+ await expect(
129
+ askJev(settings(), 's', {q: {type: 'noul', instructions: 'x'}}),
130
+ ).rejects.toBeInstanceOf(JevError);
131
+ });
132
+
133
+ test('invalid JSON raises a clear error', async () => {
134
+ stubFetch(async () => new Response('not json', {status: 200}));
135
+ await expect(
136
+ askJev(settings(), 's', {q: {type: 'noul', instructions: 'x'}}),
137
+ ).rejects.toBeInstanceOf(JevError);
138
+ });
139
+
140
+ test('a missing usage block is tolerated', async () => {
141
+ stubFetch(async () => jsonResponse({answers: {q: {type: 'noul', noul: 0.1}}}));
142
+ const res = await askJev(settings(), 's', {q: {type: 'noul', instructions: 'x'}});
143
+ expect(res.usage).toBeNull();
144
+ });
145
+
146
+ test('a transport failure surfaces as a JevError, not a raw throw', async () => {
147
+ globalThis.fetch = (async () => {
148
+ throw new Error('ECONNREFUSED');
149
+ }) as unknown as typeof fetch;
150
+ await expect(
151
+ askJev(settings(), 's', {q: {type: 'noul', instructions: 'x'}}),
152
+ ).rejects.toBeInstanceOf(JevError);
153
+ });
154
+ });
package/src/client.ts ADDED
@@ -0,0 +1,177 @@
1
+ /**
2
+ * The one place this extension talks to the network.
3
+ *
4
+ * It POSTs a System One request to the configured endpoint and nothing else:
5
+ * no telemetry, no fallback host, no redirect to another provider. If `baseUrl`
6
+ * is OpenCode Zen, that is the only host ever contacted.
7
+ */
8
+
9
+ import type {JevSettings} from './config.js';
10
+
11
+ /** A typed System One question. */
12
+ export type JevQuestion =
13
+ | {type: 'noul'; instructions: string}
14
+ | {type: 'choice'; instructions: string; criteria: Record<string, string>}
15
+ | {type: 'score'; instructions: string; criteria: string[]};
16
+
17
+ /** One answer, with the fields System One actually returns per question type. */
18
+ export interface JevAnswer {
19
+ type: 'noul' | 'choice' | 'score' | string;
20
+ /** noul: probability the answer is yes, 0..1. */
21
+ noul?: number;
22
+ /** choice: the chosen criterion id. */
23
+ choice?: string;
24
+ /** choice: confidence in the pick, 0..1. */
25
+ confidence?: number;
26
+ /** choice/score: probability per criterion id (choice) or index (score). */
27
+ probabilities?: Record<string, number>;
28
+ /** score: the expected value over the rubric, in criterion-index units. */
29
+ score?: number;
30
+ /** score: index → criterion label. */
31
+ legend?: Record<string, string>;
32
+ }
33
+
34
+ export interface JevUsage {
35
+ inputTokens: number;
36
+ outputTokens: number;
37
+ /** 0 for the free model. */
38
+ cost: number;
39
+ }
40
+
41
+ export interface JevResponse {
42
+ model: string;
43
+ answers: Record<string, JevAnswer>;
44
+ usage: JevUsage | null;
45
+ }
46
+
47
+ /** Raised for anything the caller should see as a plain tool error string. */
48
+ export class JevError extends Error {}
49
+
50
+ interface RawBody {
51
+ model?: unknown;
52
+ answers?: unknown;
53
+ usage?: unknown;
54
+ }
55
+
56
+ function parseUsage(raw: unknown): JevUsage | null {
57
+ if (!raw || typeof raw !== 'object') return null;
58
+ const u = raw as Record<string, unknown>;
59
+ const input = Number(u.input_tokens);
60
+ const output = Number(u.output_tokens);
61
+ const cost = Number(u.cost);
62
+ return {
63
+ inputTokens: Number.isFinite(input) ? input : 0,
64
+ outputTokens: Number.isFinite(output) ? output : 0,
65
+ cost: Number.isFinite(cost) ? cost : 0,
66
+ };
67
+ }
68
+
69
+ /**
70
+ * Validate one answer.
71
+ *
72
+ * Fails closed: a malformed answer for a known question type is dropped rather
73
+ * than surfaced as a plausible-looking number. A model that returns garbage
74
+ * must not read as confidence.
75
+ */
76
+ function parseAnswer(raw: unknown): JevAnswer | null {
77
+ if (!raw || typeof raw !== 'object') return null;
78
+ const a = raw as Record<string, unknown>;
79
+ if (typeof a.type !== 'string') return null;
80
+
81
+ const answer: JevAnswer = {type: a.type};
82
+
83
+ if (typeof a.noul === 'number' && Number.isFinite(a.noul)) answer.noul = a.noul;
84
+ if (typeof a.choice === 'string') answer.choice = a.choice;
85
+ if (typeof a.confidence === 'number' && Number.isFinite(a.confidence)) {
86
+ answer.confidence = a.confidence;
87
+ }
88
+ if (typeof a.score === 'number' && Number.isFinite(a.score)) answer.score = a.score;
89
+
90
+ if (a.probabilities && typeof a.probabilities === 'object') {
91
+ const probs: Record<string, number> = {};
92
+ for (const [key, value] of Object.entries(a.probabilities as Record<string, unknown>)) {
93
+ const n = Number(value);
94
+ if (Number.isFinite(n)) probs[key] = n;
95
+ }
96
+ answer.probabilities = probs;
97
+ }
98
+
99
+ if (a.legend && typeof a.legend === 'object') {
100
+ const legend: Record<string, string> = {};
101
+ for (const [key, value] of Object.entries(a.legend as Record<string, unknown>)) {
102
+ if (typeof value === 'string') legend[key] = value;
103
+ }
104
+ answer.legend = legend;
105
+ }
106
+
107
+ return answer;
108
+ }
109
+
110
+ /**
111
+ * POST a System One request.
112
+ *
113
+ * Every question is asked in one round trip; System One evaluates them in
114
+ * parallel against the same state.
115
+ */
116
+ export async function askJev(
117
+ settings: JevSettings,
118
+ state: string,
119
+ questions: Record<string, JevQuestion>,
120
+ signal?: AbortSignal,
121
+ ): Promise<JevResponse> {
122
+ if (!settings.apiKey) {
123
+ throw new JevError(
124
+ 'No Jev API key configured. Configure OpenCode Zen in pal (keys.zen in ~/.pal/config.json or OPENCODE_API_KEY), or set jev.keyEnv / jev.apiKey.',
125
+ );
126
+ }
127
+
128
+ const deadline = AbortSignal.timeout(settings.timeoutMs);
129
+ const combined = signal ? AbortSignal.any([signal, deadline]) : deadline;
130
+
131
+ let response: Response;
132
+ try {
133
+ response = await fetch(settings.baseUrl, {
134
+ method: 'POST',
135
+ headers: {
136
+ 'Content-Type': 'application/json',
137
+ Authorization: `Bearer ${settings.apiKey}`,
138
+ },
139
+ body: JSON.stringify({model: settings.model, state, questions}),
140
+ signal: combined,
141
+ });
142
+ } catch (err) {
143
+ if (deadline.aborted) {
144
+ throw new JevError(`Jev request timed out after ${settings.timeoutMs}ms.`);
145
+ }
146
+ throw new JevError(`Jev request failed: ${err instanceof Error ? err.message : String(err)}`);
147
+ }
148
+
149
+ if (!response.ok) {
150
+ // Fixed-string errors: never echo a response body that a proxy could use to
151
+ // reflect content back into the transcript.
152
+ throw new JevError(`Jev endpoint returned HTTP ${response.status}.`);
153
+ }
154
+
155
+ let body: RawBody;
156
+ try {
157
+ body = (await response.json()) as RawBody;
158
+ } catch {
159
+ throw new JevError('Jev returned a response that was not valid JSON.');
160
+ }
161
+
162
+ if (!body || typeof body !== 'object' || !body.answers || typeof body.answers !== 'object') {
163
+ throw new JevError('Jev returned no answers.');
164
+ }
165
+
166
+ const answers: Record<string, JevAnswer> = {};
167
+ for (const [id, raw] of Object.entries(body.answers as Record<string, unknown>)) {
168
+ const parsed = parseAnswer(raw);
169
+ if (parsed) answers[id] = parsed;
170
+ }
171
+
172
+ return {
173
+ model: typeof body.model === 'string' ? body.model : settings.model,
174
+ answers,
175
+ usage: parseUsage(body.usage),
176
+ };
177
+ }
@@ -0,0 +1,114 @@
1
+ import {describe, expect, test} from 'bun:test';
2
+
3
+ import {
4
+ DEFAULT_BASE_URL,
5
+ DEFAULT_MODEL,
6
+ KEY_PROVIDER,
7
+ isJevConfigured,
8
+ resolveJevSettings,
9
+ } from './config.js';
10
+
11
+ describe('resolveJevSettings', () => {
12
+ test('falls back to the Zen endpoint and the free model', () => {
13
+ const s = resolveJevSettings({}, {}, {});
14
+ expect(s.baseUrl).toBe(DEFAULT_BASE_URL);
15
+ expect(s.model).toBe(DEFAULT_MODEL);
16
+ });
17
+
18
+ test('the default endpoint is Zen System One and the default model is the free one', () => {
19
+ expect(DEFAULT_BASE_URL).toBe('https://opencode.ai/inference/systemone/v1/systemone');
20
+ expect(DEFAULT_MODEL).toBe('jev-1.13-free');
21
+ expect(KEY_PROVIDER).toBe('zen');
22
+ });
23
+
24
+ test('reuses the existing OpenCode Zen key — no duplicate storage', () => {
25
+ const s = resolveJevSettings({}, {}, {zen: 'stored-zen-key'});
26
+ expect(s.apiKey).toBe('stored-zen-key');
27
+ expect(s.keySource).toBe('config');
28
+ });
29
+
30
+ test('reports env as the source when the env var is what won', () => {
31
+ const s = resolveJevSettings({}, {OPENCODE_API_KEY: 'from-env'}, {zen: 'from-env'});
32
+ expect(s.apiKey).toBe('from-env');
33
+ expect(s.keySource).toBe('env');
34
+ });
35
+
36
+ test('is unconfigured when no key exists anywhere', () => {
37
+ const s = resolveJevSettings({}, {}, {});
38
+ expect(s.apiKey).toBe('');
39
+ expect(s.keySource).toBe('none');
40
+ expect(isJevConfigured(s)).toBe(false);
41
+ });
42
+
43
+ test('config overrides the endpoint and model', () => {
44
+ const s = resolveJevSettings(
45
+ {jev: {baseUrl: 'https://example.test/systemone', model: 'jev-1.13'}},
46
+ {},
47
+ {zen: 'k'},
48
+ );
49
+ expect(s.baseUrl).toBe('https://example.test/systemone');
50
+ expect(s.model).toBe('jev-1.13');
51
+ });
52
+
53
+ test('env overrides config for endpoint and model', () => {
54
+ const s = resolveJevSettings(
55
+ {jev: {baseUrl: 'https://config.test/x', model: 'jev-1.13'}},
56
+ {PAL_JEV_BASE_URL: 'https://env.test/y', PAL_JEV_MODEL: 'jev-1.14'},
57
+ {zen: 'k'},
58
+ );
59
+ expect(s.baseUrl).toBe('https://env.test/y');
60
+ expect(s.model).toBe('jev-1.14');
61
+ });
62
+
63
+ test('keyEnv names a different variable and beats the shared key', () => {
64
+ const s = resolveJevSettings({jev: {keyEnv: 'MY_JEV_KEY'}}, {MY_JEV_KEY: 'custom'}, {
65
+ zen: 'shared',
66
+ });
67
+ expect(s.apiKey).toBe('custom');
68
+ expect(s.keySource).toBe('env');
69
+ });
70
+
71
+ test('an inlined config key beats both and is reported as config-sourced', () => {
72
+ const s = resolveJevSettings({jev: {apiKey: 'inline'}}, {OPENCODE_API_KEY: 'env-key'}, {
73
+ zen: 'shared',
74
+ });
75
+ expect(s.apiKey).toBe('inline');
76
+ expect(s.keySource).toBe('config');
77
+ });
78
+
79
+ test('a keyEnv pointing at an unset variable falls through to the shared key', () => {
80
+ const s = resolveJevSettings({jev: {keyEnv: 'MISSING_VAR'}}, {}, {zen: 'shared'});
81
+ expect(s.apiKey).toBe('shared');
82
+ });
83
+
84
+ test('blank strings fall through to defaults instead of winning', () => {
85
+ const s = resolveJevSettings({jev: {baseUrl: ' ', model: ''}}, {}, {});
86
+ expect(s.baseUrl).toBe(DEFAULT_BASE_URL);
87
+ expect(s.model).toBe(DEFAULT_MODEL);
88
+ });
89
+
90
+ test('a malformed jev block is ignored rather than throwing', () => {
91
+ const s = resolveJevSettings({jev: 'not-an-object'}, {}, {zen: 'k'});
92
+ expect(s.baseUrl).toBe(DEFAULT_BASE_URL);
93
+ expect(s.apiKey).toBe('k');
94
+ });
95
+
96
+ test('timeout defaults and honours a positive override', () => {
97
+ expect(resolveJevSettings({}, {}, {}).timeoutMs).toBe(30_000);
98
+ expect(resolveJevSettings({jev: {timeoutMs: 5000}}, {}, {}).timeoutMs).toBe(5000);
99
+ expect(resolveJevSettings({jev: {timeoutMs: -1}}, {}, {}).timeoutMs).toBe(30_000);
100
+ expect(resolveJevSettings({jev: {timeoutMs: 'soon' as unknown}}, {}, {}).timeoutMs).toBe(
101
+ 30_000,
102
+ );
103
+ });
104
+ });
105
+
106
+ describe('isJevConfigured', () => {
107
+ test('is false without a key, so the tools are never advertised', () => {
108
+ expect(isJevConfigured(resolveJevSettings({}, {}, {}))).toBe(false);
109
+ });
110
+
111
+ test('is true once the shared Zen key resolves', () => {
112
+ expect(isJevConfigured(resolveJevSettings({}, {}, {zen: 'k'}))).toBe(true);
113
+ });
114
+ });
package/src/config.ts ADDED
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Jev (System One) settings, resolved from pal's existing config.
3
+ *
4
+ * Nothing is hardcoded and no key is stored twice: the API key comes from the
5
+ * same places every other provider key comes from — `resolveAllKeys()`, which
6
+ * already merges the `OPENCODE_API_KEY` environment variable over the
7
+ * `keys.zen` entry in `~/.pal/config.json`. If you have already configured
8
+ * OpenCode Zen in pal, Jev works with no extra setup.
9
+ *
10
+ * ~/.pal/config.json
11
+ * {
12
+ * "keys": {"zen": "oc_sk_..."}, // reused as-is
13
+ * "jev": {"model": "jev-1.13-free"} // optional overrides only
14
+ * }
15
+ *
16
+ * The endpoint and model are overridable per project or per environment.
17
+ */
18
+
19
+ import {readPalConfig, resolveAllKeys} from '@pal-code/core';
20
+ import type {ProviderKeys} from '@pal-code/core';
21
+
22
+ /** OpenCode Zen's System One endpoint. Overridable via config or env. */
23
+ export const DEFAULT_BASE_URL = 'https://opencode.ai/inference/systemone/v1/systemone';
24
+
25
+ /**
26
+ * The free Jev build on Zen. It bills at $0 and is time-limited, so the model
27
+ * stays configurable for when it retires.
28
+ */
29
+ export const DEFAULT_MODEL = 'jev-1.13-free';
30
+
31
+ /** The provider whose stored key Jev reuses. */
32
+ export const KEY_PROVIDER = 'zen';
33
+
34
+ export interface JevSettings {
35
+ /** Full POST URL for the System One endpoint. */
36
+ baseUrl: string;
37
+ /** Model id sent in the request body (e.g. `jev-1.13-free`). */
38
+ model: string;
39
+ /** Bearer token. Empty when no key is configured anywhere. */
40
+ apiKey: string;
41
+ /** Where `apiKey` came from, for diagnostics — never the key itself. */
42
+ keySource: 'config' | 'env' | 'none';
43
+ /** Per-request timeout in milliseconds. */
44
+ timeoutMs: number;
45
+ }
46
+
47
+ /** Raw `jev` block as it may appear in config. Every field is optional. */
48
+ interface RawJevConfig {
49
+ baseUrl?: unknown;
50
+ model?: unknown;
51
+ keyEnv?: unknown;
52
+ apiKey?: unknown;
53
+ timeoutMs?: unknown;
54
+ }
55
+
56
+ function readJevBlock(cfg: Record<string, unknown>): RawJevConfig {
57
+ const block = cfg.jev;
58
+ return block && typeof block === 'object' ? (block as RawJevConfig) : {};
59
+ }
60
+
61
+ function nonEmptyString(value: unknown): string | undefined {
62
+ return typeof value === 'string' && value.trim() ? value.trim() : undefined;
63
+ }
64
+
65
+ /**
66
+ * Resolve settings from config plus the environment.
67
+ *
68
+ * Both arguments are injectable so tests never touch the real process
69
+ * environment or the real config file.
70
+ *
71
+ * Key precedence, highest first:
72
+ * 1. `jev.apiKey` — an explicit, deliberately inlined key
73
+ * 2. `jev.keyEnv` — a named environment variable
74
+ * 3. the shared provider key for OpenCode Zen (env var, then `keys.zen`)
75
+ */
76
+ export function resolveJevSettings(
77
+ cfg: Record<string, unknown> = readPalConfig(),
78
+ env: Record<string, string | undefined> = process.env,
79
+ sharedKeys?: ProviderKeys,
80
+ ): JevSettings {
81
+ const raw = readJevBlock(cfg);
82
+
83
+ const baseUrl =
84
+ nonEmptyString(env.PAL_JEV_BASE_URL) ?? nonEmptyString(raw.baseUrl) ?? DEFAULT_BASE_URL;
85
+ const model = nonEmptyString(env.PAL_JEV_MODEL) ?? nonEmptyString(raw.model) ?? DEFAULT_MODEL;
86
+
87
+ const inlineKey = nonEmptyString(raw.apiKey);
88
+ const keyEnvName = nonEmptyString(raw.keyEnv);
89
+ const customEnvKey = keyEnvName ? nonEmptyString(env[keyEnvName]) : undefined;
90
+
91
+ const timeoutRaw = Number(raw.timeoutMs);
92
+ const timeoutMs =
93
+ Number.isFinite(timeoutRaw) && timeoutRaw > 0 ? Math.floor(timeoutRaw) : 30_000;
94
+
95
+ let apiKey = '';
96
+ let keySource: JevSettings['keySource'] = 'none';
97
+
98
+ if (inlineKey) {
99
+ apiKey = inlineKey;
100
+ keySource = 'config';
101
+ } else if (customEnvKey) {
102
+ apiKey = customEnvKey;
103
+ keySource = 'env';
104
+ } else {
105
+ // Reuse the key pal already holds for OpenCode Zen; no duplicate storage.
106
+ // Resolved lazily so an explicit key never triggers a config read.
107
+ const keys = sharedKeys ?? resolveAllKeys();
108
+ const shared = keys[KEY_PROVIDER];
109
+ if (shared) {
110
+ apiKey = shared;
111
+ // resolveAllKeys puts the env var ahead of the stored entry, so report
112
+ // env only when the variable is what actually won.
113
+ keySource = nonEmptyString(env.OPENCODE_API_KEY) ? 'env' : 'config';
114
+ }
115
+ }
116
+
117
+ return {baseUrl, model, apiKey, keySource, timeoutMs};
118
+ }
119
+
120
+ /** True when the extension has enough settings to make a call worth attempting. */
121
+ export function isJevConfigured(settings: JevSettings): boolean {
122
+ return settings.apiKey !== '' && settings.baseUrl !== '';
123
+ }
@@ -0,0 +1,227 @@
1
+ import {afterEach, beforeEach, describe, expect, test} from 'bun:test';
2
+
3
+ import extension from './index.js';
4
+ import {isJevConfigured, resolveJevSettings} from './config.js';
5
+
6
+ const realFetch = globalThis.fetch;
7
+ const KEY_VAR = 'OPENCODE_API_KEY';
8
+
9
+ let calls: Array<{url: string; init: RequestInit}> = [];
10
+
11
+ function stub(body: unknown, status = 200) {
12
+ globalThis.fetch = (async (url: unknown, init: unknown) => {
13
+ calls.push({url: String(url), init: init as RequestInit});
14
+ return new Response(JSON.stringify(body), {
15
+ status,
16
+ headers: {'Content-Type': 'application/json'},
17
+ });
18
+ }) as typeof fetch;
19
+ }
20
+
21
+ const handlers = extension.handlers as Record<
22
+ string,
23
+ (a: Record<string, unknown>) => Promise<string>
24
+ >;
25
+
26
+ beforeEach(() => {
27
+ calls = [];
28
+ process.env[KEY_VAR] = 'test-key';
29
+ });
30
+
31
+ afterEach(() => {
32
+ globalThis.fetch = realFetch;
33
+ delete process.env[KEY_VAR];
34
+ delete process.env.PAL_JEV_BASE_URL;
35
+ delete process.env.PAL_JEV_MODEL;
36
+ });
37
+
38
+ describe('jev extension surface', () => {
39
+ test('registers four tools with matching handlers when a key exists', () => {
40
+ expect(extension.name).toBe('jev');
41
+ const toolNames = extension.tools.map((t) => t.function.name).sort();
42
+ expect(toolNames).toEqual(['jev_ask', 'jev_check', 'jev_classify', 'jev_score']);
43
+ for (const name of toolNames) {
44
+ expect(typeof handlers[name]).toBe('function');
45
+ }
46
+ });
47
+
48
+ test('advertises no tools at all when no key is configured anywhere', () => {
49
+ // Pin both inputs empty: no config block, no env, and an empty shared-key
50
+ // map so the real ~/.pal/config.json cannot supply one.
51
+ const settings = resolveJevSettings({}, {}, {});
52
+ expect(isJevConfigured(settings)).toBe(false);
53
+ });
54
+
55
+ test('reuses the shared Zen key when present, so no second copy is needed', () => {
56
+ const settings = resolveJevSettings({}, {}, {zen: 'stored'});
57
+ expect(isJevConfigured(settings)).toBe(true);
58
+ });
59
+
60
+ test('declares availability through `available`, not by shipping zero tools', () => {
61
+ // Core cannot use "no tools" as the signal: @pal-code/mcp legitimately
62
+ // carries `tools: []` and discovers them at runtime. Only the extension
63
+ // knows whether it has nothing to offer.
64
+ expect(typeof extension.available).toBe('boolean');
65
+ expect(extension.available).toBe(true); // this machine has keys.zen
66
+ });
67
+
68
+ test('carries guidance that names its tools and when to reach for them', () => {
69
+ // The tool names carry no meaning on their own, so the prompt has to give
70
+ // the model a reason to prefer a calibrated answer over its own estimate.
71
+ const prompt = extension.prompt ?? '';
72
+ for (const name of ['jev_check', 'jev_classify', 'jev_score', 'jev_ask']) {
73
+ expect(prompt).toContain(name);
74
+ }
75
+ expect(prompt).toMatch(/calibrated/i);
76
+ });
77
+ });
78
+
79
+ describe('handlers', () => {
80
+ test('jev_check formats a probability and reports free cost', async () => {
81
+ stub({
82
+ model: 'jev-1.13-free',
83
+ answers: {answer: {type: 'noul', noul: 0.96}},
84
+ usage: {input_tokens: 290, output_tokens: 23, cost: 0},
85
+ });
86
+
87
+ const out = await handlers.jev_check({state: 'urgent?', instructions: 'Is it urgent?'});
88
+ expect(out).toContain('yes');
89
+ expect(out).toContain('P=0.960');
90
+ expect(out).toContain('$0');
91
+ });
92
+
93
+ test('jev_classify sends a choice question and ranks probabilities', async () => {
94
+ stub({
95
+ model: 'jev-1.13-free',
96
+ answers: {
97
+ answer: {
98
+ type: 'choice',
99
+ choice: 'returns',
100
+ confidence: 1,
101
+ probabilities: {returns: 1, billing: 0},
102
+ },
103
+ },
104
+ });
105
+
106
+ const out = await handlers.jev_classify({
107
+ state: 'damaged item',
108
+ instructions: 'Which team?',
109
+ options: {returns: 'refunds', billing: 'charges'},
110
+ });
111
+ expect(out).toContain('returns');
112
+
113
+ const body = JSON.parse(String(calls[0].init.body));
114
+ expect(body.questions.answer.type).toBe('choice');
115
+ expect(body.questions.answer.criteria).toEqual({returns: 'refunds', billing: 'charges'});
116
+ });
117
+
118
+ test('jev_score sends a score question and shows the legend', async () => {
119
+ stub({
120
+ model: 'jev-1.13-free',
121
+ answers: {
122
+ answer: {
123
+ type: 'score',
124
+ score: 0.99,
125
+ confidence: 0.98,
126
+ legend: {0: 'Calm', 1: 'Frustrated', 2: 'Very angry'},
127
+ probabilities: {0: 0.01, 1: 0.99, 2: 0},
128
+ },
129
+ },
130
+ });
131
+
132
+ const out = await handlers.jev_score({
133
+ state: 'angry customer',
134
+ instructions: 'How frustrated?',
135
+ criteria: ['Calm', 'Frustrated', 'Very angry'],
136
+ });
137
+ expect(out).toContain('0.990');
138
+ expect(out).toContain('Very angry');
139
+
140
+ const body = JSON.parse(String(calls[0].init.body));
141
+ expect(body.questions.answer.criteria).toEqual(['Calm', 'Frustrated', 'Very angry']);
142
+ });
143
+
144
+ test('jev_ask passes several typed questions in one request', async () => {
145
+ stub({
146
+ model: 'jev-1.13-free',
147
+ answers: {
148
+ a: {type: 'noul', noul: 0.2},
149
+ b: {type: 'choice', choice: 'x', probabilities: {x: 0.9, y: 0.1}},
150
+ },
151
+ });
152
+
153
+ const out = await handlers.jev_ask({
154
+ state: 'content',
155
+ questions: {
156
+ a: {type: 'noul', instructions: 'is a?'},
157
+ b: {type: 'choice', instructions: 'which?', criteria: {x: 'ex', y: 'why'}},
158
+ },
159
+ });
160
+ expect(out).toContain('a:');
161
+ expect(out).toContain('b:');
162
+ expect(calls).toHaveLength(1);
163
+ });
164
+
165
+ test('uses the configured base URL and model, never a hardcoded one', async () => {
166
+ process.env.PAL_JEV_BASE_URL = 'https://custom.test/systemone';
167
+ process.env.PAL_JEV_MODEL = 'jev-1.13';
168
+ stub({model: 'jev-1.13', answers: {answer: {type: 'noul', noul: 0.1}}});
169
+
170
+ await handlers.jev_check({state: 's', instructions: 'i'});
171
+
172
+ expect(calls[0].url).toBe('https://custom.test/systemone');
173
+ const body = JSON.parse(String(calls[0].init.body));
174
+ expect(body.model).toBe('jev-1.13');
175
+ });
176
+ });
177
+
178
+ describe('validation and failure', () => {
179
+ test('rejects a missing state without calling out', async () => {
180
+ stub({answers: {}});
181
+ const out = await handlers.jev_check({instructions: 'i'});
182
+ expect(out).toContain('Error:');
183
+ expect(out).toContain('state');
184
+ expect(calls).toHaveLength(0);
185
+ });
186
+
187
+ test('rejects a choice with fewer than two options', async () => {
188
+ stub({answers: {}});
189
+ const out = await handlers.jev_classify({
190
+ state: 's',
191
+ instructions: 'i',
192
+ options: {only: 'one'},
193
+ });
194
+ expect(out).toContain('at least two');
195
+ expect(calls).toHaveLength(0);
196
+ });
197
+
198
+ test('rejects a score rubric with fewer than two labels', async () => {
199
+ stub({answers: {}});
200
+ const out = await handlers.jev_score({state: 's', instructions: 'i', criteria: ['only']});
201
+ expect(out).toContain('at least two');
202
+ expect(calls).toHaveLength(0);
203
+ });
204
+
205
+ test('rejects an unknown question type in jev_ask', async () => {
206
+ stub({answers: {}});
207
+ const out = await handlers.jev_ask({
208
+ state: 's',
209
+ questions: {a: {type: 'wat', instructions: 'i'}},
210
+ });
211
+ expect(out).toContain('unsupported type');
212
+ expect(calls).toHaveLength(0);
213
+ });
214
+
215
+ // A missing key is covered at two levels instead of here, because the
216
+ // handlers resolve settings from the real config (and this machine has an
217
+ // OpenCode Zen key stored):
218
+ // - config.test.ts: isJevConfigured() is false with no key anywhere
219
+ // - client.test.ts: askJev() refuses to call out without a key
220
+
221
+ test('an HTTP failure becomes an Error string, not a throw', async () => {
222
+ stub({error: 'nope'}, 500);
223
+ const out = await handlers.jev_check({state: 's', instructions: 'i'});
224
+ expect(out).toContain('Error:');
225
+ expect(out).toContain('500');
226
+ });
227
+ });
package/src/index.ts ADDED
@@ -0,0 +1,336 @@
1
+ /**
2
+ * @pal-code/jev — Jev (System One) judgment tools for pal.
3
+ *
4
+ * Talks only to the configured System One endpoint (OpenCode Zen by default).
5
+ * First-party code: no third-party MCP server sits between pal and the API.
6
+ */
7
+
8
+ import type {ToolDef, ToolExtension, ToolHandler} from '@pal-code/core';
9
+
10
+ import {askJev, JevError} from './client.js';
11
+ import type {JevAnswer, JevQuestion} from './client.js';
12
+ import {isJevConfigured, resolveJevSettings} from './config.js';
13
+
14
+ /** Render one answer as a compact, unambiguous line. */
15
+ function formatAnswer(id: string, answer: JevAnswer): string {
16
+ if (answer.type === 'noul' && typeof answer.noul === 'number') {
17
+ const pct = (answer.noul * 100).toFixed(1);
18
+ return `${id}: ${answer.noul >= 0.5 ? 'yes' : 'no'} (P=${answer.noul.toFixed(3)}, ${pct}%)`;
19
+ }
20
+
21
+ if (answer.type === 'choice' && answer.choice !== undefined) {
22
+ const parts = [`${id}: ${answer.choice}`];
23
+ if (typeof answer.confidence === 'number')
24
+ parts.push(`confidence=${answer.confidence.toFixed(3)}`);
25
+ if (answer.probabilities) {
26
+ const ranked = Object.entries(answer.probabilities)
27
+ .sort((a, b) => b[1] - a[1])
28
+ .map(([k, v]) => `${k}=${v.toFixed(3)}`)
29
+ .join(', ');
30
+ parts.push(`[${ranked}]`);
31
+ }
32
+ return parts.join(' ');
33
+ }
34
+
35
+ if (answer.type === 'score' && typeof answer.score === 'number') {
36
+ const legend = answer.legend ? answer.legend : {};
37
+ const nearest = Math.round(answer.score);
38
+ const label = legend[String(nearest)];
39
+ const parts = [`${id}: ${answer.score.toFixed(3)}${label ? ` (≈${label})` : ''}`];
40
+ if (typeof answer.confidence === 'number')
41
+ parts.push(`confidence=${answer.confidence.toFixed(3)}`);
42
+ if (Object.keys(legend).length > 0) {
43
+ const scale = Object.entries(legend)
44
+ .sort((a, b) => Number(a[0]) - Number(b[0]))
45
+ .map(([k, v]) => `${k}=${v}`)
46
+ .join(', ');
47
+ parts.push(`scale=[${scale}]`);
48
+ }
49
+ return parts.join(' ');
50
+ }
51
+
52
+ return `${id}: ${JSON.stringify(answer)}`;
53
+ }
54
+
55
+ function formatResponse(
56
+ model: string,
57
+ answers: Record<string, JevAnswer>,
58
+ usage: {inputTokens: number; outputTokens: number; cost: number} | null,
59
+ ): string {
60
+ const ids = Object.keys(answers);
61
+ if (ids.length === 0) {
62
+ return 'Jev returned no usable answers (the response failed validation).';
63
+ }
64
+
65
+ const lines = ids.map((id) => formatAnswer(id, answers[id]));
66
+ const cost = usage ? ` · ${usage.inputTokens}in/${usage.outputTokens}out · $${usage.cost}` : '';
67
+ return `${model}${cost}\n${lines.join('\n')}`;
68
+ }
69
+
70
+ /** Wrap a handler so every failure becomes a readable tool error. */
71
+ function guard<A>(fn: (args: A) => Promise<string>): ToolHandler {
72
+ return async (raw) => {
73
+ try {
74
+ return await fn(raw as A);
75
+ } catch (err) {
76
+ if (err instanceof JevError) return `Error: ${err.message}`;
77
+ return `Error: ${err instanceof Error ? err.message : String(err)}`;
78
+ }
79
+ };
80
+ }
81
+
82
+ const noulDef: ToolDef = {
83
+ type: 'function',
84
+ function: {
85
+ name: 'jev_check',
86
+ description:
87
+ 'Ask Jev a yes/no question about a state and get a calibrated probability. Use for gates, filters, and guardrails where a boolean plus confidence is more useful than prose.',
88
+ parameters: {
89
+ type: 'object',
90
+ properties: {
91
+ state: {type: 'string', description: 'The content to judge'},
92
+ instructions: {type: 'string', description: 'The yes/no question to ask about the state'},
93
+ },
94
+ required: ['state', 'instructions'],
95
+ },
96
+ },
97
+ };
98
+
99
+ const choiceDef: ToolDef = {
100
+ type: 'function',
101
+ function: {
102
+ name: 'jev_classify',
103
+ description:
104
+ 'Pick exactly one option from a labelled set, with confidence and the full probability distribution. Use for routing, categorization, and intent detection.',
105
+ parameters: {
106
+ type: 'object',
107
+ properties: {
108
+ state: {type: 'string', description: 'The content to judge'},
109
+ instructions: {type: 'string', description: 'What is being decided'},
110
+ options: {
111
+ type: 'object',
112
+ description: 'Option id → a precise description of what belongs in it',
113
+ additionalProperties: {type: 'string'},
114
+ },
115
+ },
116
+ required: ['state', 'instructions', 'options'],
117
+ },
118
+ },
119
+ };
120
+
121
+ const scoreDef: ToolDef = {
122
+ type: 'function',
123
+ function: {
124
+ name: 'jev_score',
125
+ description:
126
+ 'Rate a state on an ordered rubric and get a score plus the per-level distribution. Use for risk, severity, urgency, or quality ratings.',
127
+ parameters: {
128
+ type: 'object',
129
+ properties: {
130
+ state: {type: 'string', description: 'The content to judge'},
131
+ instructions: {type: 'string', description: 'What is being rated'},
132
+ criteria: {
133
+ type: 'array',
134
+ description: 'Ordered rubric labels, lowest to highest (at least two)',
135
+ items: {type: 'string'},
136
+ },
137
+ },
138
+ required: ['state', 'instructions', 'criteria'],
139
+ },
140
+ },
141
+ };
142
+
143
+ const askDef: ToolDef = {
144
+ type: 'function',
145
+ function: {
146
+ name: 'jev_ask',
147
+ description:
148
+ 'Ask several typed questions about one state in a single round trip. Jev evaluates them in parallel. Prefer this over repeated single-question calls when you need more than one judgment on the same content.',
149
+ parameters: {
150
+ type: 'object',
151
+ properties: {
152
+ state: {type: 'string', description: 'The content every question is judged against'},
153
+ questions: {
154
+ type: 'object',
155
+ description:
156
+ 'Question id → question. Each question is {type: "noul", instructions} for yes/no, {type: "choice", instructions, criteria: {id: description}} for one-of, or {type: "score", instructions, criteria: [labels]} for a rubric.',
157
+ },
158
+ },
159
+ required: ['state', 'questions'],
160
+ },
161
+ },
162
+ };
163
+
164
+ /** Reject a call rather than sending a request Jev cannot answer. */
165
+ function requireString(value: unknown, field: string): string {
166
+ if (typeof value !== 'string' || !value.trim()) {
167
+ throw new JevError(`\`${field}\` must be a non-empty string.`);
168
+ }
169
+ return value;
170
+ }
171
+
172
+ function settingsOrThrow() {
173
+ const settings = resolveJevSettings();
174
+ if (!isJevConfigured(settings)) {
175
+ throw new JevError(
176
+ 'No Jev API key configured. Configure OpenCode Zen in pal (keys.zen in ~/.pal/config.json or OPENCODE_API_KEY), or set jev.keyEnv / jev.apiKey.',
177
+ );
178
+ }
179
+ return settings;
180
+ }
181
+
182
+ const handlers: Record<string, ToolHandler> = {
183
+ jev_check: guard(async (args: {state?: unknown; instructions?: unknown}) => {
184
+ const settings = settingsOrThrow();
185
+ const state = requireString(args.state, 'state');
186
+ const instructions = requireString(args.instructions, 'instructions');
187
+ const res = await askJev(settings, state, {answer: {type: 'noul', instructions}});
188
+ return formatResponse(res.model, res.answers, res.usage);
189
+ }),
190
+
191
+ jev_classify: guard(
192
+ async (args: {state?: unknown; instructions?: unknown; options?: unknown}) => {
193
+ const settings = settingsOrThrow();
194
+ const state = requireString(args.state, 'state');
195
+ const instructions = requireString(args.instructions, 'instructions');
196
+
197
+ if (!args.options || typeof args.options !== 'object') {
198
+ throw new JevError('`options` must be an object of option id → description.');
199
+ }
200
+ const criteria: Record<string, string> = {};
201
+ for (const [key, value] of Object.entries(args.options as Record<string, unknown>)) {
202
+ if (typeof value !== 'string' || !value.trim()) {
203
+ throw new JevError(`Option "${key}" must have a non-empty description.`);
204
+ }
205
+ criteria[key] = value;
206
+ }
207
+ if (Object.keys(criteria).length < 2) {
208
+ throw new JevError('`options` needs at least two entries.');
209
+ }
210
+
211
+ const res = await askJev(settings, state, {
212
+ answer: {type: 'choice', instructions, criteria},
213
+ });
214
+ return formatResponse(res.model, res.answers, res.usage);
215
+ },
216
+ ),
217
+
218
+ jev_score: guard(async (args: {state?: unknown; instructions?: unknown; criteria?: unknown}) => {
219
+ const settings = settingsOrThrow();
220
+ const state = requireString(args.state, 'state');
221
+ const instructions = requireString(args.instructions, 'instructions');
222
+
223
+ if (!Array.isArray(args.criteria) || args.criteria.length < 2) {
224
+ throw new JevError('`criteria` must be an array of at least two ordered labels.');
225
+ }
226
+ const criteria = args.criteria.map((c, i) => {
227
+ if (typeof c !== 'string' || !c.trim()) {
228
+ throw new JevError(`criterion ${i} must be a non-empty string.`);
229
+ }
230
+ return c;
231
+ });
232
+
233
+ const res = await askJev(settings, state, {answer: {type: 'score', instructions, criteria}});
234
+ return formatResponse(res.model, res.answers, res.usage);
235
+ }),
236
+
237
+ jev_ask: guard(async (args: {state?: unknown; questions?: unknown}) => {
238
+ const settings = settingsOrThrow();
239
+ const state = requireString(args.state, 'state');
240
+
241
+ if (!args.questions || typeof args.questions !== 'object') {
242
+ throw new JevError('`questions` must be an object of question id → question.');
243
+ }
244
+
245
+ const questions: Record<string, JevQuestion> = {};
246
+ for (const [id, raw] of Object.entries(args.questions as Record<string, unknown>)) {
247
+ if (!raw || typeof raw !== 'object') {
248
+ throw new JevError(`Question "${id}" must be an object.`);
249
+ }
250
+ const q = raw as Record<string, unknown>;
251
+ const type = q.type;
252
+ if (type !== 'noul' && type !== 'choice' && type !== 'score') {
253
+ throw new JevError(`Question "${id}" has an unsupported type "${String(type)}".`);
254
+ }
255
+ const instructions = requireString(q.instructions, `${id}.instructions`);
256
+
257
+ if (type === 'noul') {
258
+ questions[id] = {type: 'noul', instructions};
259
+ } else if (type === 'choice') {
260
+ if (!q.criteria || typeof q.criteria !== 'object') {
261
+ throw new JevError(`Choice question "${id}" needs a \`criteria\` object.`);
262
+ }
263
+ questions[id] = {
264
+ type: 'choice',
265
+ instructions,
266
+ criteria: q.criteria as Record<string, string>,
267
+ };
268
+ } else {
269
+ if (!Array.isArray(q.criteria) || q.criteria.length < 2) {
270
+ throw new JevError(`Score question "${id}" needs a \`criteria\` array of two or more.`);
271
+ }
272
+ questions[id] = {
273
+ type: 'score',
274
+ instructions,
275
+ criteria: q.criteria as string[],
276
+ };
277
+ }
278
+ }
279
+
280
+ if (Object.keys(questions).length === 0) {
281
+ throw new JevError('`questions` must contain at least one question.');
282
+ }
283
+
284
+ const res = await askJev(settings, state, questions);
285
+ return formatResponse(res.model, res.answers, res.usage);
286
+ }),
287
+ };
288
+
289
+ /**
290
+ * Whether Jev can be used at all.
291
+ *
292
+ * Without a key, exposing four tools that can only ever return "no API key
293
+ * configured" wastes the model's attention and teaches it to distrust the
294
+ * toolset. `available` is how this extension tells core to drop it entirely:
295
+ * no tools, no prompt, no lifecycle — an unconfigured install is
296
+ * indistinguishable from one that was never installed.
297
+ *
298
+ * Deliberately not a "tools are empty so we're inert" convention: `@pal-code/mcp`
299
+ * legitimately carries tools discovered at runtime from `setup()`, so emptiness
300
+ * cannot be the signal. Only the extension knows why it has nothing to offer.
301
+ */
302
+ function isAvailable(): boolean {
303
+ return isJevConfigured(resolveJevSettings());
304
+ }
305
+
306
+ /**
307
+ * Guidance the tool schemas cannot express.
308
+ *
309
+ * The tool names (`jev_check`, `jev_classify`, …) mean nothing to a model that
310
+ * has not seen Jev before, so the descriptions carry the whole load. This text
311
+ * names the moments where a calibrated answer beats an estimate — the model has
312
+ * no other reason to reach for a second opinion instead of just answering.
313
+ *
314
+ * Appended only while the extension is loaded and available, so a user without
315
+ * a key pays nothing for it.
316
+ */
317
+ const PROMPT = [
318
+ 'JUDGMENT: For yes/no gates, routing between fixed options, and risk or',
319
+ 'severity ratings, prefer a calibrated answer over your own guess — call',
320
+ '`jev_check`, `jev_classify`, or `jev_score` (or `jev_ask` for several at once)',
321
+ 'and use the returned probability. Do not use them for facts about files or',
322
+ 'code you can read directly; they judge a state you describe, they do not',
323
+ 'retrieve anything.',
324
+ ].join(' ');
325
+
326
+ export default {
327
+ name: 'jev',
328
+ get available() {
329
+ return isAvailable();
330
+ },
331
+ get tools() {
332
+ return isAvailable() ? [noulDef, choiceDef, scoreDef, askDef] : [];
333
+ },
334
+ prompt: PROMPT,
335
+ handlers,
336
+ } satisfies ToolExtension;
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.