jev-recipes 0.6.0 → 0.7.0

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.
Files changed (84) hide show
  1. package/README.md +57 -11
  2. package/dist/catalog/generated/details/completion-gate.json +110 -0
  3. package/dist/catalog/generated/details/context-prune.json +59 -0
  4. package/dist/catalog/generated/details/diff-hazards.json +112 -0
  5. package/dist/catalog/generated/details/finger-actions.json +95 -0
  6. package/dist/catalog/generated/details/model-route.json +82 -0
  7. package/dist/catalog/generated/details/route-many.json +68 -0
  8. package/dist/catalog/generated/details/tool-call-gate.json +123 -0
  9. package/dist/catalog/generated/details/wake-gate.json +40 -0
  10. package/dist/catalog/generated/loaders.js +8 -0
  11. package/dist/catalog/generated/metadata.js +240 -14
  12. package/dist/catalog/generated/names.d.ts +1 -1
  13. package/dist/catalog/generated/names.js +8 -0
  14. package/dist/catalog/schema.d.ts +8 -0
  15. package/dist/cli/schema.d.ts +24 -0
  16. package/dist/recipes/cancellation-check/schema.d.ts +6 -6
  17. package/dist/recipes/clarify/index.js +2 -2
  18. package/dist/recipes/completion-gate/demo.json +29 -0
  19. package/dist/recipes/completion-gate/index.d.ts +5 -0
  20. package/dist/recipes/completion-gate/index.js +53 -0
  21. package/dist/recipes/completion-gate/schema.d.ts +103 -0
  22. package/dist/recipes/completion-gate/schema.js +33 -0
  23. package/dist/recipes/context-prune/demo.json +40 -0
  24. package/dist/recipes/context-prune/index.d.ts +5 -0
  25. package/dist/recipes/context-prune/index.js +42 -0
  26. package/dist/recipes/context-prune/schema.d.ts +58 -0
  27. package/dist/recipes/context-prune/schema.js +23 -0
  28. package/dist/recipes/diff-hazards/demo.json +18 -0
  29. package/dist/recipes/diff-hazards/index.d.ts +5 -0
  30. package/dist/recipes/diff-hazards/index.js +48 -0
  31. package/dist/recipes/diff-hazards/schema.d.ts +96 -0
  32. package/dist/recipes/diff-hazards/schema.js +24 -0
  33. package/dist/recipes/extraction-fidelity/schema.d.ts +2 -2
  34. package/dist/recipes/finger-actions/demo.json +58 -0
  35. package/dist/recipes/finger-actions/index.d.ts +5 -0
  36. package/dist/recipes/finger-actions/index.js +7 -0
  37. package/dist/recipes/finger-actions/schema.d.ts +48 -0
  38. package/dist/recipes/finger-actions/schema.js +10 -0
  39. package/dist/recipes/handoff/schema.d.ts +1 -1
  40. package/dist/recipes/model-route/demo.json +45 -0
  41. package/dist/recipes/model-route/index.d.ts +5 -0
  42. package/dist/recipes/model-route/index.js +35 -0
  43. package/dist/recipes/model-route/schema.d.ts +51 -0
  44. package/dist/recipes/model-route/schema.js +16 -0
  45. package/dist/recipes/mood-match/schema.d.ts +2 -2
  46. package/dist/recipes/performance-feedback-facets/demo.json +1 -1
  47. package/dist/recipes/performance-feedback-facets/index.js +2 -2
  48. package/dist/recipes/product-match/schema.d.ts +2 -2
  49. package/dist/recipes/route-many/demo.json +53 -0
  50. package/dist/recipes/route-many/index.d.ts +5 -0
  51. package/dist/recipes/route-many/index.js +48 -0
  52. package/dist/recipes/route-many/schema.d.ts +49 -0
  53. package/dist/recipes/route-many/schema.js +30 -0
  54. package/dist/recipes/sound-match/schema.d.ts +2 -2
  55. package/dist/recipes/step-complete/demo.json +1 -1
  56. package/dist/recipes/step-complete/index.js +2 -2
  57. package/dist/recipes/symptom-facets/demo.json +1 -1
  58. package/dist/recipes/symptom-facets/index.js +3 -3
  59. package/dist/recipes/tool-call-gate/demo.json +26 -0
  60. package/dist/recipes/tool-call-gate/index.d.ts +5 -0
  61. package/dist/recipes/tool-call-gate/index.js +67 -0
  62. package/dist/recipes/tool-call-gate/schema.d.ts +134 -0
  63. package/dist/recipes/tool-call-gate/schema.js +34 -0
  64. package/dist/recipes/trip-purpose-kind/schema.d.ts +3 -3
  65. package/dist/recipes/verify/index.js +4 -3
  66. package/dist/recipes/wake-gate/demo.json +20 -0
  67. package/dist/recipes/wake-gate/index.d.ts +5 -0
  68. package/dist/recipes/wake-gate/index.js +16 -0
  69. package/dist/recipes/wake-gate/schema.d.ts +40 -0
  70. package/dist/recipes/wake-gate/schema.js +15 -0
  71. package/dist/src/answers.js +10 -4
  72. package/dist/src/assignments.d.ts +2 -0
  73. package/dist/src/assignments.js +47 -0
  74. package/dist/src/batch.d.ts +12 -0
  75. package/dist/src/batch.js +23 -0
  76. package/dist/src/fanout.d.ts +20 -0
  77. package/dist/src/fanout.js +39 -0
  78. package/dist/src/index.d.ts +16 -0
  79. package/dist/src/index.js +8 -0
  80. package/dist/src/schema.d.ts +70 -0
  81. package/dist/src/schema.js +27 -0
  82. package/dist/src/selection.d.ts +18 -0
  83. package/dist/src/selection.js +41 -11
  84. package/package.json +38 -3
@@ -0,0 +1,5 @@
1
+ import type { RecipeOptions } from '../../src/schema.js';
2
+ import type { ContextPruneInput, ContextPruneResult } from './schema.js';
3
+ export declare function contextPrune(input: ContextPruneInput, options?: RecipeOptions): Promise<ContextPruneResult>;
4
+ export { contextPruneInputSchema, contextPruneResultSchema, contextPruneItemSchema, contextPruneVerdictSchema, } from './schema.js';
5
+ export type { ContextPruneInput, ContextPruneResult, ContextPruneItem, ContextPruneVerdict, } from './schema.js';
@@ -0,0 +1,42 @@
1
+ import { noul } from '@typesafe-ai/sdk';
2
+ import { evaluateWithJev } from '../../src/client.js';
3
+ import { parseYesProbability } from '../../src/answers.js';
4
+ import { asDecisionInstruction, parseDecisionState } from '../../src/decisions.js';
5
+ import { contextPruneInputSchema, contextPruneResultSchema } from './schema.js';
6
+ export async function contextPrune(input, options = {}) {
7
+ const { minConfidence = 0.8, ...state } = contextPruneInputSchema.parse(input);
8
+ const response = await evaluateWithJev({
9
+ state: parseDecisionState(state),
10
+ questions: Object.fromEntries(state.items.map((_, index) => [
11
+ `item_${index}`,
12
+ noul(asDecisionInstruction(`Will items[${index}].text still be needed to finish objective? Count it needed when it holds facts, results, decisions, errors, or user instructions the remaining work depends on, or when it is the only record of something that must not be redone. Do not count it needed merely because it was useful earlier, is long, or is recent; use recent, when supplied, for what has already been handled. Judge only this item.`), {
13
+ true: 'The remaining work depends on this item.',
14
+ false: 'The remaining work can proceed without this item.',
15
+ }),
16
+ ])),
17
+ }, options);
18
+ const items = state.items.map((item, index) => {
19
+ const probability = parseYesProbability(response.answers[`item_${index}`]);
20
+ const confidence = Math.max(probability, 1 - probability);
21
+ return {
22
+ id: item.id,
23
+ status: confidence < minConfidence ? 'review' : 'ready',
24
+ verdict: probability >= 0.5 ? 'keep' : 'drop',
25
+ probability,
26
+ confidence,
27
+ };
28
+ });
29
+ const drop = items
30
+ .filter((item) => item.status === 'ready' && item.verdict === 'drop')
31
+ .map((item) => item.id);
32
+ return contextPruneResultSchema.parse({
33
+ status: items.some((item) => item.status === 'review') ? 'review' : 'ready',
34
+ items,
35
+ keep: items.filter((item) => !drop.includes(item.id)).map((item) => item.id),
36
+ drop,
37
+ evaluated: items.length,
38
+ model: response.model,
39
+ usage: response.usage,
40
+ });
41
+ }
42
+ export { contextPruneInputSchema, contextPruneResultSchema, contextPruneItemSchema, contextPruneVerdictSchema, } from './schema.js';
@@ -0,0 +1,58 @@
1
+ import { z } from 'zod';
2
+ export declare const contextPruneVerdictSchema: z.ZodEnum<{
3
+ keep: "keep";
4
+ drop: "drop";
5
+ }>;
6
+ export declare const contextPruneInputSchema: z.ZodObject<{
7
+ objective: z.ZodString;
8
+ items: z.ZodArray<z.ZodObject<{
9
+ id: z.ZodString;
10
+ text: z.ZodString;
11
+ }, z.core.$strip>>;
12
+ recent: z.ZodOptional<z.ZodString>;
13
+ minConfidence: z.ZodOptional<z.ZodNumber>;
14
+ }, z.core.$strip>;
15
+ export declare const contextPruneItemSchema: z.ZodObject<{
16
+ id: z.ZodString;
17
+ status: z.ZodEnum<{
18
+ ready: "ready";
19
+ review: "review";
20
+ }>;
21
+ verdict: z.ZodEnum<{
22
+ keep: "keep";
23
+ drop: "drop";
24
+ }>;
25
+ probability: z.ZodNumber;
26
+ confidence: z.ZodNumber;
27
+ }, z.core.$strip>;
28
+ export declare const contextPruneResultSchema: z.ZodObject<{
29
+ model: z.ZodString;
30
+ usage: z.ZodObject<{
31
+ input_tokens: z.ZodNumber;
32
+ output_tokens: z.ZodNumber;
33
+ }, z.core.$strip>;
34
+ status: z.ZodEnum<{
35
+ ready: "ready";
36
+ review: "review";
37
+ }>;
38
+ items: z.ZodArray<z.ZodObject<{
39
+ id: z.ZodString;
40
+ status: z.ZodEnum<{
41
+ ready: "ready";
42
+ review: "review";
43
+ }>;
44
+ verdict: z.ZodEnum<{
45
+ keep: "keep";
46
+ drop: "drop";
47
+ }>;
48
+ probability: z.ZodNumber;
49
+ confidence: z.ZodNumber;
50
+ }, z.core.$strip>>;
51
+ keep: z.ZodArray<z.ZodString>;
52
+ drop: z.ZodArray<z.ZodString>;
53
+ evaluated: z.ZodNumber;
54
+ }, z.core.$strip>;
55
+ export type ContextPruneVerdict = z.infer<typeof contextPruneVerdictSchema>;
56
+ export type ContextPruneInput = z.infer<typeof contextPruneInputSchema>;
57
+ export type ContextPruneItem = z.infer<typeof contextPruneItemSchema>;
58
+ export type ContextPruneResult = z.infer<typeof contextPruneResultSchema>;
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ import { decisionStatusSchema, nonEmptyText, probability, resultMetadataSchema, textItemsSchema, } from '../../src/schema.js';
3
+ export const contextPruneVerdictSchema = z.enum(['keep', 'drop']);
4
+ export const contextPruneInputSchema = z.object({
5
+ objective: nonEmptyText,
6
+ items: textItemsSchema,
7
+ recent: nonEmptyText.optional(),
8
+ minConfidence: probability.optional(),
9
+ });
10
+ export const contextPruneItemSchema = z.object({
11
+ id: nonEmptyText,
12
+ status: decisionStatusSchema,
13
+ verdict: contextPruneVerdictSchema,
14
+ probability,
15
+ confidence: probability,
16
+ });
17
+ export const contextPruneResultSchema = resultMetadataSchema.extend({
18
+ status: decisionStatusSchema,
19
+ items: z.array(contextPruneItemSchema),
20
+ keep: z.array(nonEmptyText),
21
+ drop: z.array(nonEmptyText),
22
+ evaluated: z.number().int().nonnegative(),
23
+ });
@@ -0,0 +1,18 @@
1
+ {
2
+ "input": {
3
+ "diff": "--- a/src/payments.ts\n+++ b/src/payments.ts\n@@ -1,6 +1,9 @@\n import { Stripe } from 'stripe';\n-const stripe = new Stripe(process.env.STRIPE_KEY);\n+const stripe = new Stripe('sk_prod_51Hq9zLKj3mD8vXyZ2pQ7rT4wN6bF0cE1gA5hJ8kL');\n+console.log('DEBUG charge payload', payload);\n export async function charge(payload) {\n return stripe.charges.create(payload);\n }",
4
+ "context": "Pre-commit screen for a payments service.",
5
+ "minConfidence": 0.8
6
+ },
7
+ "response": {
8
+ "model": "demo-fixture",
9
+ "answers": {
10
+ "secretLeak": { "type": "noul", "noul": 0.97 },
11
+ "destructiveCommand": { "type": "noul", "noul": 0.03 },
12
+ "debugLeftover": { "type": "noul", "noul": 0.93 },
13
+ "testsWeakened": { "type": "noul", "noul": 0.04 },
14
+ "dependencyChange": { "type": "noul", "noul": 0.05 }
15
+ },
16
+ "usage": { "input_tokens": 0, "output_tokens": 0 }
17
+ }
18
+ }
@@ -0,0 +1,5 @@
1
+ import type { RecipeOptions } from '../../src/schema.js';
2
+ import type { DiffHazardsInput, DiffHazardsResult } from './schema.js';
3
+ export declare function diffHazards(input: DiffHazardsInput, options?: RecipeOptions): Promise<DiffHazardsResult>;
4
+ export { diffHazardsInputSchema, diffHazardsResultSchema, diffHazardsLabelSchema, } from './schema.js';
5
+ export type { DiffHazardsInput, DiffHazardsResult, DiffHazardsLabel } from './schema.js';
@@ -0,0 +1,48 @@
1
+ import { evaluateLabels, resolveLabels } from '../../src/labels.js';
2
+ import { diffHazardsInputSchema, diffHazardsResultSchema } from './schema.js';
3
+ export async function diffHazards(input, options = {}) {
4
+ const { minConfidence = 0.8, ...state } = diffHazardsInputSchema.parse(input);
5
+ const evaluation = await evaluateLabels(state, {
6
+ secretLeak: {
7
+ instruction: 'Does diff add a credential, API key, token, password, private key, or connection string containing a secret? Placeholders such as YOUR_KEY_HERE, environment variable references, and clearly fake example values do not count.',
8
+ criteria: {
9
+ true: 'The diff adds what appears to be a real secret value.',
10
+ false: 'The diff adds no secret value, or only placeholders and references.',
11
+ },
12
+ },
13
+ destructiveCommand: {
14
+ instruction: 'Does diff add a command or statement that deletes, drops, truncates, overwrites, or force-pushes data or history, such as rm -rf, DROP TABLE, TRUNCATE, git push --force, or a migration that removes columns or rows?',
15
+ criteria: {
16
+ true: 'The diff adds a destructive command or data-removing statement.',
17
+ false: 'The diff adds no destructive command.',
18
+ },
19
+ },
20
+ debugLeftover: {
21
+ instruction: 'Does diff add debugging artifacts that should not ship, such as print or console.log statements used for tracing, debugger statements, commented-out code blocks, hard-coded test values, or notes like TODO remove or HACK?',
22
+ criteria: {
23
+ true: 'The diff adds debugging or scaffolding leftovers.',
24
+ false: 'The diff adds no debugging leftovers, or only intentional logging.',
25
+ },
26
+ },
27
+ testsWeakened: {
28
+ instruction: 'Does diff remove or weaken tests, for example by deleting test cases, skipping or disabling tests, removing assertions, loosening expected values, or adding broad exception catches inside tests?',
29
+ criteria: {
30
+ true: 'The diff removes, skips, or weakens tests.',
31
+ false: 'The diff leaves tests as strong as before or strengthens them.',
32
+ },
33
+ },
34
+ dependencyChange: {
35
+ instruction: 'Does diff add, remove, or change the version of a third-party dependency, for example in package.json, requirements.txt, go.mod, Cargo.toml, a lockfile, or an import of a package that is not already used?',
36
+ criteria: {
37
+ true: "The diff changes the project's third-party dependencies.",
38
+ false: 'The diff does not change dependencies.',
39
+ },
40
+ },
41
+ }, options);
42
+ return diffHazardsResultSchema.parse({
43
+ ...resolveLabels(evaluation.labels, minConfidence),
44
+ model: evaluation.model,
45
+ usage: evaluation.usage,
46
+ });
47
+ }
48
+ export { diffHazardsInputSchema, diffHazardsResultSchema, diffHazardsLabelSchema, } from './schema.js';
@@ -0,0 +1,96 @@
1
+ import { z } from 'zod';
2
+ export declare const diffHazardsLabelSchema: z.ZodEnum<{
3
+ secretLeak: "secretLeak";
4
+ destructiveCommand: "destructiveCommand";
5
+ debugLeftover: "debugLeftover";
6
+ testsWeakened: "testsWeakened";
7
+ dependencyChange: "dependencyChange";
8
+ }>;
9
+ export declare const diffHazardsInputSchema: z.ZodObject<{
10
+ diff: z.ZodString;
11
+ context: z.ZodOptional<z.ZodString>;
12
+ minConfidence: z.ZodOptional<z.ZodNumber>;
13
+ }, z.core.$strip>;
14
+ export declare const diffHazardsResultSchema: z.ZodObject<{
15
+ model: z.ZodString;
16
+ usage: z.ZodObject<{
17
+ input_tokens: z.ZodNumber;
18
+ output_tokens: z.ZodNumber;
19
+ }, z.core.$strip>;
20
+ status: z.ZodEnum<{
21
+ ready: "ready";
22
+ review: "review";
23
+ }>;
24
+ detected: z.ZodArray<z.ZodEnum<{
25
+ secretLeak: "secretLeak";
26
+ destructiveCommand: "destructiveCommand";
27
+ debugLeftover: "debugLeftover";
28
+ testsWeakened: "testsWeakened";
29
+ dependencyChange: "dependencyChange";
30
+ }>>;
31
+ labels: z.ZodObject<{
32
+ secretLeak: z.ZodObject<{
33
+ status: z.ZodEnum<{
34
+ ready: "ready";
35
+ review: "review";
36
+ }>;
37
+ verdict: z.ZodEnum<{
38
+ present: "present";
39
+ absent: "absent";
40
+ }>;
41
+ probability: z.ZodNumber;
42
+ confidence: z.ZodNumber;
43
+ }, z.core.$strip>;
44
+ destructiveCommand: z.ZodObject<{
45
+ status: z.ZodEnum<{
46
+ ready: "ready";
47
+ review: "review";
48
+ }>;
49
+ verdict: z.ZodEnum<{
50
+ present: "present";
51
+ absent: "absent";
52
+ }>;
53
+ probability: z.ZodNumber;
54
+ confidence: z.ZodNumber;
55
+ }, z.core.$strip>;
56
+ debugLeftover: z.ZodObject<{
57
+ status: z.ZodEnum<{
58
+ ready: "ready";
59
+ review: "review";
60
+ }>;
61
+ verdict: z.ZodEnum<{
62
+ present: "present";
63
+ absent: "absent";
64
+ }>;
65
+ probability: z.ZodNumber;
66
+ confidence: z.ZodNumber;
67
+ }, z.core.$strip>;
68
+ testsWeakened: z.ZodObject<{
69
+ status: z.ZodEnum<{
70
+ ready: "ready";
71
+ review: "review";
72
+ }>;
73
+ verdict: z.ZodEnum<{
74
+ present: "present";
75
+ absent: "absent";
76
+ }>;
77
+ probability: z.ZodNumber;
78
+ confidence: z.ZodNumber;
79
+ }, z.core.$strip>;
80
+ dependencyChange: z.ZodObject<{
81
+ status: z.ZodEnum<{
82
+ ready: "ready";
83
+ review: "review";
84
+ }>;
85
+ verdict: z.ZodEnum<{
86
+ present: "present";
87
+ absent: "absent";
88
+ }>;
89
+ probability: z.ZodNumber;
90
+ confidence: z.ZodNumber;
91
+ }, z.core.$strip>;
92
+ }, z.core.$strip>;
93
+ }, z.core.$strip>;
94
+ export type DiffHazardsLabel = z.infer<typeof diffHazardsLabelSchema>;
95
+ export type DiffHazardsInput = z.infer<typeof diffHazardsInputSchema>;
96
+ export type DiffHazardsResult = z.infer<typeof diffHazardsResultSchema>;
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ import { labelCheckSchema, labelsResultSchema, nonEmptyText, probability, } from '../../src/schema.js';
3
+ export const diffHazardsLabelSchema = z.enum([
4
+ 'secretLeak',
5
+ 'destructiveCommand',
6
+ 'debugLeftover',
7
+ 'testsWeakened',
8
+ 'dependencyChange',
9
+ ]);
10
+ export const diffHazardsInputSchema = z.object({
11
+ diff: nonEmptyText,
12
+ context: nonEmptyText.optional(),
13
+ minConfidence: probability.optional(),
14
+ });
15
+ export const diffHazardsResultSchema = labelsResultSchema.extend({
16
+ detected: z.array(diffHazardsLabelSchema),
17
+ labels: z.object({
18
+ secretLeak: labelCheckSchema,
19
+ destructiveCommand: labelCheckSchema,
20
+ debugLeftover: labelCheckSchema,
21
+ testsWeakened: labelCheckSchema,
22
+ dependencyChange: labelCheckSchema,
23
+ }),
24
+ });
@@ -1,8 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  export declare const extractionFidelityVerdictSchema: z.ZodEnum<{
3
+ exact: "exact";
3
4
  low: "low";
4
5
  high: "high";
5
- exact: "exact";
6
6
  poor: "poor";
7
7
  fair: "fair";
8
8
  }>;
@@ -26,9 +26,9 @@ export declare const extractionFidelityResultSchema: z.ZodObject<{
26
26
  confidence: z.ZodNumber;
27
27
  probabilities: z.ZodRecord<z.ZodString, z.ZodNumber>;
28
28
  fidelity: z.ZodEnum<{
29
+ exact: "exact";
29
30
  low: "low";
30
31
  high: "high";
31
- exact: "exact";
32
32
  poor: "poor";
33
33
  fair: "fair";
34
34
  }>;
@@ -0,0 +1,58 @@
1
+ {
2
+ "input": {
3
+ "music": "Key C major, 72 bpm, gentle ballad. Last bar: right hand melody E4 D4 C4 (quarter, quarter, half) over a C major chord held in the left hand. The phrase just ended on the tonic.",
4
+ "beat": "Bar 5, eighth 1, start of a new phrase",
5
+ "fingers": [
6
+ {
7
+ "id": "rh-thumb",
8
+ "text": "Right thumb, resting on C4, free to move",
9
+ "options": [
10
+ { "id": "c4", "text": "Press C4 to restate the tonic" },
11
+ { "id": "hold", "text": "Keep C4 sounding from the previous bar" }
12
+ ]
13
+ },
14
+ {
15
+ "id": "rh-index",
16
+ "text": "Right index, hovering over D4 and E4",
17
+ "options": [
18
+ { "id": "e4", "text": "Press E4 to start the melody a third above" },
19
+ { "id": "d4", "text": "Press D4 to start stepwise" }
20
+ ]
21
+ },
22
+ {
23
+ "id": "lh-pinky",
24
+ "text": "Left pinky, on C3 which is currently sounding",
25
+ "options": [
26
+ { "id": "c3", "text": "Re-strike C3 for a fresh bass note" },
27
+ { "id": "g2", "text": "Move down to G2 for a dominant pedal" }
28
+ ]
29
+ }
30
+ ],
31
+ "style": "Keep the texture sparse; melody on top, single bass notes below.",
32
+ "minConfidence": 0.8
33
+ },
34
+ "response": {
35
+ "model": "demo-fixture",
36
+ "answers": {
37
+ "finger_0": {
38
+ "type": "choice",
39
+ "choice": "rest",
40
+ "confidence": 0.84,
41
+ "probabilities": { "option_0": 0.08, "option_1": 0.06, "rest": 0.84, "ambiguous": 0.02 }
42
+ },
43
+ "finger_1": {
44
+ "type": "choice",
45
+ "choice": "option_0",
46
+ "confidence": 0.86,
47
+ "probabilities": { "option_0": 0.86, "option_1": 0.1, "rest": 0.03, "ambiguous": 0.01 }
48
+ },
49
+ "finger_2": {
50
+ "type": "choice",
51
+ "choice": "option_0",
52
+ "confidence": 0.9,
53
+ "probabilities": { "option_0": 0.9, "option_1": 0.06, "rest": 0.03, "ambiguous": 0.01 }
54
+ }
55
+ },
56
+ "usage": { "input_tokens": 0, "output_tokens": 0 }
57
+ }
58
+ }
@@ -0,0 +1,5 @@
1
+ import type { RecipeOptions } from '../../src/schema.js';
2
+ import type { FingerActionsInput, FingerActionsResult } from './schema.js';
3
+ export declare function fingerActions(input: FingerActionsInput, options?: RecipeOptions): Promise<FingerActionsResult>;
4
+ export { fingerActionsInputSchema, fingerActionsResultSchema } from './schema.js';
5
+ export type { FingerActionsInput, FingerActionsResult } from './schema.js';
@@ -0,0 +1,7 @@
1
+ import { evaluateAssignments } from '../../src/assignments.js';
2
+ import { fingerActionsInputSchema } from './schema.js';
3
+ export async function fingerActions(input, options = {}) {
4
+ const { minConfidence = 0.8, ...state } = fingerActionsInputSchema.parse(input);
5
+ return evaluateAssignments(state, state.fingers, (index) => `What should fingers[${index}] (described in fingers[${index}].text) do on beat, given the recent material, key, and tempo in music and any style? Choose one of its listed options so the whole hand plays a coherent, idiomatic voicing with the other fingers' likely actions. Judge only this finger.`, minConfidence, options, 'finger');
6
+ }
7
+ export { fingerActionsInputSchema, fingerActionsResultSchema } from './schema.js';
@@ -0,0 +1,48 @@
1
+ import { z } from 'zod';
2
+ export declare const fingerActionsInputSchema: z.ZodObject<{
3
+ music: z.ZodString;
4
+ beat: z.ZodString;
5
+ fingers: z.ZodArray<z.ZodObject<{
6
+ id: z.ZodString;
7
+ text: z.ZodString;
8
+ options: z.ZodArray<z.ZodObject<{
9
+ id: z.ZodString;
10
+ text: z.ZodString;
11
+ }, z.core.$strip>>;
12
+ }, z.core.$strip>>;
13
+ style: z.ZodOptional<z.ZodString>;
14
+ minConfidence: z.ZodOptional<z.ZodNumber>;
15
+ }, z.core.$strip>;
16
+ export declare const fingerActionsResultSchema: z.ZodObject<{
17
+ model: z.ZodString;
18
+ usage: z.ZodObject<{
19
+ input_tokens: z.ZodNumber;
20
+ output_tokens: z.ZodNumber;
21
+ }, z.core.$strip>;
22
+ status: z.ZodEnum<{
23
+ ready: "ready";
24
+ review: "review";
25
+ }>;
26
+ assignments: z.ZodArray<z.ZodObject<{
27
+ id: z.ZodString;
28
+ status: z.ZodEnum<{
29
+ ready: "ready";
30
+ review: "review";
31
+ }>;
32
+ verdict: z.ZodEnum<{
33
+ ambiguous: "ambiguous";
34
+ chosen: "chosen";
35
+ rest: "rest";
36
+ }>;
37
+ action: z.ZodNullable<z.ZodString>;
38
+ suggestedAction: z.ZodNullable<z.ZodString>;
39
+ confidence: z.ZodNumber;
40
+ probabilities: z.ZodObject<{
41
+ options: z.ZodRecord<z.ZodString, z.ZodNumber>;
42
+ rest: z.ZodNumber;
43
+ ambiguous: z.ZodNumber;
44
+ }, z.core.$strip>;
45
+ }, z.core.$strip>>;
46
+ }, z.core.$strip>;
47
+ export type FingerActionsInput = z.infer<typeof fingerActionsInputSchema>;
48
+ export type FingerActionsResult = z.infer<typeof fingerActionsResultSchema>;
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ import { assignmentsResultSchema, nonEmptyText, optionSlotsSchema, probability, } from '../../src/schema.js';
3
+ export const fingerActionsInputSchema = z.object({
4
+ music: nonEmptyText,
5
+ beat: nonEmptyText,
6
+ fingers: optionSlotsSchema,
7
+ style: nonEmptyText.optional(),
8
+ minConfidence: probability.optional(),
9
+ });
10
+ export const fingerActionsResultSchema = assignmentsResultSchema;
@@ -29,8 +29,8 @@ export declare const handoffResultSchema: z.ZodObject<{
29
29
  }>;
30
30
  decision: z.ZodEnum<{
31
31
  review: "review";
32
- human: "human";
33
32
  continue: "continue";
33
+ human: "human";
34
34
  }>;
35
35
  matchedRules: z.ZodArray<z.ZodString>;
36
36
  uncertainRules: z.ZodArray<z.ZodString>;
@@ -0,0 +1,45 @@
1
+ {
2
+ "input": {
3
+ "request": "Rename the variable `usr` to `user` in src/session.ts and fix any references.",
4
+ "models": [
5
+ {
6
+ "id": "fast",
7
+ "text": "Small, cheap, fast model. Good for edits with one obvious approach, reformatting, short answers, and simple lookups. Weak at multi-step reasoning and subtle bugs."
8
+ },
9
+ {
10
+ "id": "balanced",
11
+ "text": "Mid-size model at moderate cost. Handles multi-file changes, explanations, and routine debugging. Occasionally misses subtle design issues."
12
+ },
13
+ {
14
+ "id": "frontier",
15
+ "text": "Largest, slowest, most expensive model. Best for architecture, security-sensitive code, ambiguous requirements, and hard debugging."
16
+ }
17
+ ],
18
+ "context": "Coding agent inside a small TypeScript repository with tests.",
19
+ "minConfidence": 0.8
20
+ },
21
+ "response": {
22
+ "model": "demo-fixture",
23
+ "answers": {
24
+ "decision": {
25
+ "type": "choice",
26
+ "choice": "candidate_0",
27
+ "confidence": 0.92,
28
+ "probabilities": {
29
+ "candidate_0": 0.92,
30
+ "candidate_1": 0.05,
31
+ "candidate_2": 0.01,
32
+ "none": 0.01,
33
+ "ambiguous": 0.01
34
+ }
35
+ },
36
+ "effort": {
37
+ "type": "score",
38
+ "score": 0.1,
39
+ "confidence": 0.9,
40
+ "probabilities": { "0": 0.9, "1": 0.1, "2": 0 }
41
+ }
42
+ },
43
+ "usage": { "input_tokens": 0, "output_tokens": 0 }
44
+ }
45
+ }
@@ -0,0 +1,5 @@
1
+ import type { RecipeOptions } from '../../src/schema.js';
2
+ import type { ModelRouteInput, ModelRouteResult } from './schema.js';
3
+ export declare function modelRoute(input: ModelRouteInput, options?: RecipeOptions): Promise<ModelRouteResult>;
4
+ export { modelRouteInputSchema, modelRouteResultSchema, modelRouteEffortSchema } from './schema.js';
5
+ export type { ModelRouteInput, ModelRouteResult, ModelRouteEffort } from './schema.js';
@@ -0,0 +1,35 @@
1
+ import { score } from '@typesafe-ai/sdk';
2
+ import { evaluateWithJev } from '../../src/client.js';
3
+ import { parseScoreAnswer } from '../../src/answers.js';
4
+ import { parseDecisionState } from '../../src/decisions.js';
5
+ import { asScoreInstruction } from '../../src/scores.js';
6
+ import { resolveSelection, selectionQuestion } from '../../src/selection.js';
7
+ import { modelRouteInputSchema, modelRouteResultSchema, modelRouteEffortSchema } from './schema.js';
8
+ const EFFORT_RUBRIC = [
9
+ 'A direct lookup, small edit, reformat, or short factual answer with one obvious approach and little risk if slightly wrong.',
10
+ 'A task with a few interacting parts, some judgment about approach, or moderate consequences, such as a multi-file change or an explanation that must be accurate.',
11
+ 'A task that needs careful multi-step reasoning, novel design, subtle debugging, or where a mistake is costly, such as architecture decisions, security-sensitive code, or ambiguous requirements.',
12
+ ];
13
+ export async function modelRoute(input, options = {}) {
14
+ const { minConfidence = 0.8, ...state } = modelRouteInputSchema.parse(input);
15
+ const response = await evaluateWithJev({
16
+ state: parseDecisionState(state),
17
+ questions: {
18
+ decision: selectionQuestion(state.models, 'Which of models should handle request, given any context? Each model describes its strengths, weaknesses, and cost. Prefer the cheapest model whose described capabilities clearly cover the request; escalate only when the request needs a capability a cheaper model lacks.'),
19
+ effort: score(asScoreInstruction('How much reasoning effort does request need to be handled well, given any context?', EFFORT_RUBRIC), EFFORT_RUBRIC),
20
+ },
21
+ }, options);
22
+ const selection = resolveSelection(response.answers.decision, state.models, minConfidence);
23
+ const effort = parseScoreAnswer(response.answers.effort, EFFORT_RUBRIC.length);
24
+ return modelRouteResultSchema.parse({
25
+ ...selection,
26
+ effort: modelRouteEffortSchema.options[effort.level],
27
+ effortLevel: effort.level,
28
+ effortScore: effort.score,
29
+ effortConfidence: effort.confidence,
30
+ effortProbabilities: effort.probabilities,
31
+ model: response.model,
32
+ usage: response.usage,
33
+ });
34
+ }
35
+ export { modelRouteInputSchema, modelRouteResultSchema, modelRouteEffortSchema } from './schema.js';
@@ -0,0 +1,51 @@
1
+ import { z } from 'zod';
2
+ export declare const modelRouteEffortSchema: z.ZodEnum<{
3
+ low: "low";
4
+ high: "high";
5
+ medium: "medium";
6
+ }>;
7
+ export declare const modelRouteInputSchema: z.ZodObject<{
8
+ request: z.ZodString;
9
+ models: z.ZodArray<z.ZodObject<{
10
+ id: z.ZodString;
11
+ text: z.ZodString;
12
+ }, z.core.$strip>>;
13
+ context: z.ZodOptional<z.ZodString>;
14
+ minConfidence: z.ZodOptional<z.ZodNumber>;
15
+ }, z.core.$strip>;
16
+ export declare const modelRouteResultSchema: z.ZodObject<{
17
+ model: z.ZodString;
18
+ usage: z.ZodObject<{
19
+ input_tokens: z.ZodNumber;
20
+ output_tokens: z.ZodNumber;
21
+ }, z.core.$strip>;
22
+ status: z.ZodEnum<{
23
+ ready: "ready";
24
+ review: "review";
25
+ }>;
26
+ verdict: z.ZodEnum<{
27
+ matched: "matched";
28
+ none: "none";
29
+ ambiguous: "ambiguous";
30
+ }>;
31
+ selection: z.ZodNullable<z.ZodString>;
32
+ suggestedSelection: z.ZodNullable<z.ZodString>;
33
+ confidence: z.ZodNumber;
34
+ probabilities: z.ZodObject<{
35
+ candidates: z.ZodRecord<z.ZodString, z.ZodNumber>;
36
+ none: z.ZodNumber;
37
+ ambiguous: z.ZodNumber;
38
+ }, z.core.$strip>;
39
+ effort: z.ZodEnum<{
40
+ low: "low";
41
+ high: "high";
42
+ medium: "medium";
43
+ }>;
44
+ effortLevel: z.ZodNumber;
45
+ effortScore: z.ZodNumber;
46
+ effortConfidence: z.ZodNumber;
47
+ effortProbabilities: z.ZodRecord<z.ZodString, z.ZodNumber>;
48
+ }, z.core.$strip>;
49
+ export type ModelRouteEffort = z.infer<typeof modelRouteEffortSchema>;
50
+ export type ModelRouteInput = z.infer<typeof modelRouteInputSchema>;
51
+ export type ModelRouteResult = z.infer<typeof modelRouteResultSchema>;
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ import { nonEmptyText, probability, selectionResultSchema, textItemsSchema, } from '../../src/schema.js';
3
+ export const modelRouteEffortSchema = z.enum(['low', 'medium', 'high']);
4
+ export const modelRouteInputSchema = z.object({
5
+ request: nonEmptyText,
6
+ models: textItemsSchema,
7
+ context: nonEmptyText.optional(),
8
+ minConfidence: probability.optional(),
9
+ });
10
+ export const modelRouteResultSchema = selectionResultSchema.extend({
11
+ effort: modelRouteEffortSchema,
12
+ effortLevel: z.number().int().min(0).max(2),
13
+ effortScore: z.number().min(0).max(2),
14
+ effortConfidence: probability,
15
+ effortProbabilities: z.record(z.string(), probability),
16
+ });