wizards 0.2.24 → 0.2.26
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/apps/runtime/dist/agents/architect.js +5 -0
- package/apps/runtime/dist/authoring/guide.js +55 -6
- package/apps/runtime/dist/connectors/builtin.js +17 -1
- package/apps/runtime/dist/connectors/imap.js +46 -2
- package/apps/runtime/dist/connectors/index.js +52 -18
- package/apps/runtime/dist/connectors/via-account.js +63 -0
- package/apps/runtime/dist/credits/estimate.js +12 -2
- package/apps/runtime/dist/engine/decide.js +82 -0
- package/apps/runtime/dist/engine/input.js +12 -5
- package/apps/runtime/dist/engine/requirements.js +80 -15
- package/apps/runtime/dist/engine/runner.js +252 -6
- package/apps/runtime/dist/engine/steps.js +206 -18
- package/apps/runtime/dist/engine/surface.js +90 -0
- package/apps/runtime/dist/render/downloads.js +7 -0
- package/apps/runtime/dist/routes/runs.js +18 -5
- package/apps/runtime/dist/services/relevance.js +17 -49
- package/apps/runtime/dist/tools/pages.js +31 -6
- package/apps/web/dist/assets/{Account-thPW7H4A.js → Account-Cnksw5Ea.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-mCszGL5_.js → ChangelogDialog-CdtQWq0m.js} +1 -1
- package/apps/web/dist/assets/{CreditsDialog-Com2Y3g8.js → CreditsDialog-Ti43boCN.js} +1 -1
- package/apps/web/dist/assets/EditorPage-N7EzlRSj.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-CRsxtwhV.js → FlowPreview-IZcNrBJi.js} +1 -1
- package/apps/web/dist/assets/{Harness-CfgVRYpr.js → Harness-Cj-k02TA.js} +1 -1
- package/apps/web/dist/assets/{HomePage-DYKF3C1U.js → HomePage-bjdKkt84.js} +1 -1
- package/apps/web/dist/assets/{ImportWizard-BTp7XTsF.js → ImportWizard-DagFXYPM.js} +1 -1
- package/apps/web/dist/assets/{LocalRuntime-CYhPXwAv.js → LocalRuntime-Boi_zqQJ.js} +1 -1
- package/apps/web/dist/assets/NewWizardPage-DO5J8OpZ.js +2 -0
- package/apps/web/dist/assets/ProjectPage-DdG9wYsd.js +2 -0
- package/apps/web/dist/assets/{PublicRunner-ClB2-2EF.js → PublicRunner-B4ts9rT6.js} +1 -1
- package/apps/web/dist/assets/RunDrawer-LnVfCiYO.js +4 -0
- package/apps/web/dist/assets/RunnerView-DwffK7AA.js +70 -0
- package/apps/web/dist/assets/{SettingsPage-qDqiZ7th.js → SettingsPage-Cyx_jTlp.js} +1 -1
- package/apps/web/dist/assets/{SetupPage-BeBReYLP.js → SetupPage-CBDD4rpC.js} +1 -1
- package/apps/web/dist/assets/{SharePage-Cv8toByB.js → SharePage-70niRKaO.js} +1 -1
- package/apps/web/dist/assets/{api-rJBQEu1G.js → api-C4M6cbpW.js} +1 -1
- package/apps/web/dist/assets/changelog-COyL1B5X.js +1 -0
- package/apps/web/dist/assets/definition-DoCLtZZL.js +55 -0
- package/apps/web/dist/assets/{esm-DFNBMDKB.js → esm-CfW8Rmtq.js} +1 -1
- package/apps/web/dist/assets/index-CJ0YJ5HC.css +1 -0
- package/apps/web/dist/assets/{index-CoTWrikR.js → index-DMKXnSf-.js} +3 -3
- package/apps/web/dist/assets/meta-6jZygxJq.js +1 -0
- package/apps/web/dist/assets/{settings-menu-bsLDpw56.js → settings-menu-Dph4yXbO.js} +1 -1
- package/apps/web/dist/assets/{table-2-BdDuBcF2.js → star-UHmZXpjA.js} +1 -1
- package/apps/web/dist/assets/ui-BS348L4M.js +1 -0
- package/apps/web/dist/assets/wand-sparkles-IEd4jkyn.js +1 -0
- package/apps/web/dist/index.html +4 -4
- package/apps/web/dist/mcp/flow.html +60 -60
- package/node_modules/@engenty-wizards/shared/dist/decision.d.ts +76 -0
- package/node_modules/@engenty-wizards/shared/dist/decision.js +147 -0
- package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +1048 -50
- package/node_modules/@engenty-wizards/shared/dist/definition.js +516 -43
- package/node_modules/@engenty-wizards/shared/dist/marketplace-entry.js +19 -2
- package/node_modules/@engenty-wizards/shared/dist/marketplace.d.ts +1 -1
- package/node_modules/@engenty-wizards/shared/dist/run.d.ts +55 -0
- package/node_modules/@engenty-wizards/shared/dist/run.js +3 -0
- package/node_modules/@engenty-wizards/shared/dist/surface.d.ts +89 -0
- package/node_modules/@engenty-wizards/shared/dist/surface.js +198 -0
- package/package.json +1 -1
- package/apps/web/dist/assets/EditorPage-Dwg-K4UI.js +0 -2
- package/apps/web/dist/assets/NewWizardPage-BgnrGN8A.js +0 -2
- package/apps/web/dist/assets/ProjectPage-Cfco8MIG.js +0 -5
- package/apps/web/dist/assets/RunDrawer-B50sCUSw.js +0 -1
- package/apps/web/dist/assets/RunnerView-CFCmOmJI.js +0 -70
- package/apps/web/dist/assets/changelog-BmS3l433.js +0 -1
- package/apps/web/dist/assets/definition-BznNdlhf.js +0 -55
- package/apps/web/dist/assets/index-BZs1IxAk.css +0 -1
- package/apps/web/dist/assets/meta-DJta2rA3.js +0 -1
- package/apps/web/dist/assets/ui-DJOZSSKo.js +0 -1
- package/apps/web/dist/assets/wand-sparkles-Clj3VRB5.js +0 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Decisions: typed questions over a state, answered by a decision model (System One: TypeSafe's
|
|
4
|
+
* Jev and models of its kind) or, where there is none, by a language model asked for the same
|
|
5
|
+
* answers as structured output. Both ways give the same shapes; only a decision model gives
|
|
6
|
+
* probabilities that mean something.
|
|
7
|
+
*/
|
|
8
|
+
/** Yes or no: P(yes). */
|
|
9
|
+
export interface NoulQuestion {
|
|
10
|
+
type: "noul";
|
|
11
|
+
instructions: string;
|
|
12
|
+
criteria?: {
|
|
13
|
+
true: string;
|
|
14
|
+
false: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** One of named options, each with what it covers (null: the name says it). */
|
|
18
|
+
export interface ChoiceQuestion {
|
|
19
|
+
type: "choice";
|
|
20
|
+
instructions: string;
|
|
21
|
+
criteria: Record<string, string | null>;
|
|
22
|
+
}
|
|
23
|
+
/** A level on an ordered scale, lowest first. */
|
|
24
|
+
export interface ScoreQuestion {
|
|
25
|
+
type: "score";
|
|
26
|
+
instructions: string;
|
|
27
|
+
criteria: string[];
|
|
28
|
+
}
|
|
29
|
+
export type DecisionQuestion = NoulQuestion | ChoiceQuestion | ScoreQuestion;
|
|
30
|
+
export interface NoulAnswer {
|
|
31
|
+
type: "noul";
|
|
32
|
+
/** P(yes), 0–1. A language model's answer is 1 or 0. */
|
|
33
|
+
noul: number;
|
|
34
|
+
}
|
|
35
|
+
export interface ChoiceAnswer {
|
|
36
|
+
type: "choice";
|
|
37
|
+
choice: string;
|
|
38
|
+
/** Per option; only from a decision model. */
|
|
39
|
+
probabilities?: Record<string, number>;
|
|
40
|
+
confidence?: number;
|
|
41
|
+
}
|
|
42
|
+
export interface ScoreAnswer {
|
|
43
|
+
type: "score";
|
|
44
|
+
/** Index of the level, lowest = 0. */
|
|
45
|
+
level: number;
|
|
46
|
+
/** The level's description, as the question lists it. */
|
|
47
|
+
label: string;
|
|
48
|
+
/** Per level index; only from a decision model. */
|
|
49
|
+
probabilities?: Record<string, number>;
|
|
50
|
+
confidence?: number;
|
|
51
|
+
}
|
|
52
|
+
export type DecisionAnswer = NoulAnswer | ChoiceAnswer | ScoreAnswer;
|
|
53
|
+
export type DecisionSource = "systemone" | "llm";
|
|
54
|
+
export interface Decision {
|
|
55
|
+
answers: Record<string, DecisionAnswer>;
|
|
56
|
+
/** Which way answered; with both, the language model filled what the decision model left open. */
|
|
57
|
+
source: DecisionSource;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The answers a System One response gives that fit their questions; a question whose answer is
|
|
61
|
+
* missing or does not fit is left out, for the language model to answer.
|
|
62
|
+
*/
|
|
63
|
+
export declare function readSystemOne(questions: Record<string, DecisionQuestion>, response: unknown): Record<string, DecisionAnswer>;
|
|
64
|
+
/** The questions as one structured-output object a language model fills. */
|
|
65
|
+
export declare function decisionSchema(questions: Record<string, DecisionQuestion>): z.ZodObject<{
|
|
66
|
+
[x: string]: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
/** What a language model filled in, as answers; null when it does not fit. */
|
|
69
|
+
export declare function readObject(questions: Record<string, DecisionQuestion>, object: unknown): Record<string, DecisionAnswer> | null;
|
|
70
|
+
/**
|
|
71
|
+
* How sure the answer is that it picked rightly, as the margin between the winner and the
|
|
72
|
+
* runner-up; null where there are no probabilities (a language model's answer).
|
|
73
|
+
*/
|
|
74
|
+
export declare function marginOf(answer: DecisionAnswer): number | null;
|
|
75
|
+
/** The probability of what was answered: P(yes) for a yes/no, P(pick) otherwise; 1 without. */
|
|
76
|
+
export declare function pOf(answer: DecisionAnswer): number;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Probabilities sum to one within rounding. */
|
|
3
|
+
const SUM_TOLERANCE = 0.02;
|
|
4
|
+
function unit(v) {
|
|
5
|
+
return typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 1;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A distribution over exactly the offered keys that sums to one, with `pick` on top — so a
|
|
9
|
+
* malformed or cut-off answer never counts. Engenty-pro's validateChoiceAnswer.
|
|
10
|
+
*/
|
|
11
|
+
function validDistribution(probabilities, offered, pick) {
|
|
12
|
+
if (!probabilities || typeof probabilities !== "object") {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const p = probabilities;
|
|
16
|
+
const keys = Object.keys(p);
|
|
17
|
+
if (keys.length !== offered.length || !offered.every((k) => k in p)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
let sum = 0;
|
|
21
|
+
let max = 0;
|
|
22
|
+
for (const k of keys) {
|
|
23
|
+
if (!unit(p[k])) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
sum += p[k];
|
|
27
|
+
max = Math.max(max, p[k]);
|
|
28
|
+
}
|
|
29
|
+
return Math.abs(sum - 1) < SUM_TOLERANCE && p[pick] >= max - 1e-6;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The answers a System One response gives that fit their questions; a question whose answer is
|
|
33
|
+
* missing or does not fit is left out, for the language model to answer.
|
|
34
|
+
*/
|
|
35
|
+
export function readSystemOne(questions, response) {
|
|
36
|
+
const raw = response?.answers ?? {};
|
|
37
|
+
const out = {};
|
|
38
|
+
for (const [name, q] of Object.entries(questions)) {
|
|
39
|
+
const a = raw[name];
|
|
40
|
+
if (!a || typeof a !== "object") {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (q.type === "noul" && a.type === "noul" && unit(a.noul)) {
|
|
44
|
+
out[name] = { type: "noul", noul: a.noul };
|
|
45
|
+
}
|
|
46
|
+
else if (q.type === "choice" && a.type === "choice") {
|
|
47
|
+
const offered = Object.keys(q.criteria);
|
|
48
|
+
if (typeof a.choice === "string" &&
|
|
49
|
+
offered.includes(a.choice) &&
|
|
50
|
+
validDistribution(a.probabilities, offered, a.choice)) {
|
|
51
|
+
out[name] = {
|
|
52
|
+
type: "choice",
|
|
53
|
+
choice: a.choice,
|
|
54
|
+
probabilities: a.probabilities,
|
|
55
|
+
...(unit(a.confidence) ? { confidence: a.confidence } : {}),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (q.type === "score" && a.type === "score") {
|
|
60
|
+
const offered = q.criteria.map((_, i) => String(i));
|
|
61
|
+
const probabilities = a.probabilities;
|
|
62
|
+
const top = probabilities
|
|
63
|
+
? Object.entries(probabilities).sort((x, y) => y[1] - x[1])[0]?.[0]
|
|
64
|
+
: undefined;
|
|
65
|
+
if (top !== undefined && validDistribution(probabilities, offered, top)) {
|
|
66
|
+
const level = Number(top);
|
|
67
|
+
out[name] = {
|
|
68
|
+
type: "score",
|
|
69
|
+
level,
|
|
70
|
+
label: q.criteria[level],
|
|
71
|
+
probabilities,
|
|
72
|
+
...(unit(a.confidence) ? { confidence: a.confidence } : {}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
/** The questions as one structured-output object a language model fills. */
|
|
80
|
+
export function decisionSchema(questions) {
|
|
81
|
+
const shape = {};
|
|
82
|
+
for (const [name, q] of Object.entries(questions)) {
|
|
83
|
+
if (q.type === "noul") {
|
|
84
|
+
const hint = q.criteria ? ` (true: ${q.criteria.true}; false: ${q.criteria.false})` : "";
|
|
85
|
+
shape[name] = z.boolean().describe(`${q.instructions}${hint}`);
|
|
86
|
+
}
|
|
87
|
+
else if (q.type === "choice") {
|
|
88
|
+
const options = Object.keys(q.criteria);
|
|
89
|
+
const hints = Object.entries(q.criteria)
|
|
90
|
+
.filter(([, d]) => d)
|
|
91
|
+
.map(([k, d]) => `${k}: ${d}`)
|
|
92
|
+
.join("; ");
|
|
93
|
+
shape[name] = z
|
|
94
|
+
.enum(options)
|
|
95
|
+
.describe(hints ? `${q.instructions} (${hints})` : q.instructions);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
shape[name] = z
|
|
99
|
+
.enum(q.criteria)
|
|
100
|
+
.describe(`${q.instructions} (lowest to highest)`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return z.object(shape);
|
|
104
|
+
}
|
|
105
|
+
/** What a language model filled in, as answers; null when it does not fit. */
|
|
106
|
+
export function readObject(questions, object) {
|
|
107
|
+
if (!object || typeof object !== "object") {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const o = object;
|
|
111
|
+
const out = {};
|
|
112
|
+
for (const [name, q] of Object.entries(questions)) {
|
|
113
|
+
const v = o[name];
|
|
114
|
+
if (q.type === "noul" && typeof v === "boolean") {
|
|
115
|
+
out[name] = { type: "noul", noul: v ? 1 : 0 };
|
|
116
|
+
}
|
|
117
|
+
else if (q.type === "choice" && typeof v === "string" && v in q.criteria) {
|
|
118
|
+
out[name] = { type: "choice", choice: v };
|
|
119
|
+
}
|
|
120
|
+
else if (q.type === "score" && typeof v === "string" && q.criteria.includes(v)) {
|
|
121
|
+
out[name] = { type: "score", level: q.criteria.indexOf(v), label: v };
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return out;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* How sure the answer is that it picked rightly, as the margin between the winner and the
|
|
131
|
+
* runner-up; null where there are no probabilities (a language model's answer).
|
|
132
|
+
*/
|
|
133
|
+
export function marginOf(answer) {
|
|
134
|
+
if (answer.type === "noul") {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
const p = Object.values(answer.probabilities ?? {}).sort((a, b) => b - a);
|
|
138
|
+
return p.length >= 2 ? p[0] - p[1] : null;
|
|
139
|
+
}
|
|
140
|
+
/** The probability of what was answered: P(yes) for a yes/no, P(pick) otherwise; 1 without. */
|
|
141
|
+
export function pOf(answer) {
|
|
142
|
+
if (answer.type === "noul") {
|
|
143
|
+
return answer.noul;
|
|
144
|
+
}
|
|
145
|
+
const key = answer.type === "choice" ? answer.choice : String(answer.level);
|
|
146
|
+
return answer.probabilities?.[key] ?? 1;
|
|
147
|
+
}
|