@originkit/ai-engine 0.1.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.
- package/dist/benchmark/agents.d.ts +162 -0
- package/dist/benchmark/agents.d.ts.map +1 -0
- package/dist/benchmark/agents.js +1187 -0
- package/dist/benchmark/agents.js.map +1 -0
- package/dist/benchmark/diff.d.ts +23 -0
- package/dist/benchmark/diff.d.ts.map +1 -0
- package/dist/benchmark/diff.js +117 -0
- package/dist/benchmark/diff.js.map +1 -0
- package/dist/benchmark/domain.d.ts +8 -0
- package/dist/benchmark/domain.d.ts.map +1 -0
- package/dist/benchmark/domain.js +322 -0
- package/dist/benchmark/domain.js.map +1 -0
- package/dist/benchmark/edit-pass.d.ts +38 -0
- package/dist/benchmark/edit-pass.d.ts.map +1 -0
- package/dist/benchmark/edit-pass.js +121 -0
- package/dist/benchmark/edit-pass.js.map +1 -0
- package/dist/benchmark/prompt.d.ts +128 -0
- package/dist/benchmark/prompt.d.ts.map +1 -0
- package/dist/benchmark/prompt.js +883 -0
- package/dist/benchmark/prompt.js.map +1 -0
- package/dist/benchmark/run-loop.d.ts +74 -0
- package/dist/benchmark/run-loop.d.ts.map +1 -0
- package/dist/benchmark/run-loop.js +138 -0
- package/dist/benchmark/run-loop.js.map +1 -0
- package/dist/benchmark/schema.d.ts +13 -0
- package/dist/benchmark/schema.d.ts.map +1 -0
- package/dist/benchmark/schema.js +63 -0
- package/dist/benchmark/schema.js.map +1 -0
- package/dist/benchmark/types.d.ts +113 -0
- package/dist/benchmark/types.d.ts.map +1 -0
- package/dist/benchmark/types.js +18 -0
- package/dist/benchmark/types.js.map +1 -0
- package/dist/packages/ai-engine/index.d.ts +13 -0
- package/dist/packages/ai-engine/index.d.ts.map +1 -0
- package/dist/packages/ai-engine/index.js +39 -0
- package/dist/packages/ai-engine/index.js.map +1 -0
- package/package.json +26 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { ComponentSpec, PropSpec } from "./types.ts";
|
|
2
|
+
import type { Extract } from "./types.ts";
|
|
3
|
+
/** How a criterion gets checked. The split is the whole point: `image` is free
|
|
4
|
+
* and certain, `judge` is neither, and mixing them loses both properties. */
|
|
5
|
+
export type Check = "image" | "source" | "judge";
|
|
6
|
+
export type Criterion = {
|
|
7
|
+
text: string;
|
|
8
|
+
check: Check;
|
|
9
|
+
};
|
|
10
|
+
export type Intent = {
|
|
11
|
+
/** The implementation prompt handed to the editing model in place of the
|
|
12
|
+
* user's sentence. */
|
|
13
|
+
prompt: string;
|
|
14
|
+
/** props = a patch can do this. code = the file has to change. */
|
|
15
|
+
route: "props" | "code";
|
|
16
|
+
/** What must NOT move. Injected into the edit prompt and checked afterwards. */
|
|
17
|
+
constraints: string[];
|
|
18
|
+
criteria: Criterion[];
|
|
19
|
+
/** Set when the request is too ambiguous to implement. Blocks the turn.
|
|
20
|
+
* Short — this is read at a glance, not studied. */
|
|
21
|
+
question: string | null;
|
|
22
|
+
/** Answers to tap instead of type. Two or three words each: the point of
|
|
23
|
+
* asking is to cost the user a second, and a paragraph of options costs
|
|
24
|
+
* more than guessing would have. */
|
|
25
|
+
options: string[];
|
|
26
|
+
};
|
|
27
|
+
export type Verdict = {
|
|
28
|
+
/** Should the editor try again? NOT "is this correct" — a criterion nobody
|
|
29
|
+
* could check is not grounds for spending another call on it. */
|
|
30
|
+
pass: boolean;
|
|
31
|
+
/** Confirmed. Anything the critic could not check appears in NEITHER list —
|
|
32
|
+
* `met.length + failed.length < criteria.length` is the honest signal that
|
|
33
|
+
* part of the turn went unverified, and the UI shows it as such. */
|
|
34
|
+
met: string[];
|
|
35
|
+
failed: string[];
|
|
36
|
+
/** What to tell the editing model on the retry. Null on a pass. */
|
|
37
|
+
correction: string | null;
|
|
38
|
+
};
|
|
39
|
+
export declare function buildIntentSystem(entry: ComponentSpec, values: Record<string, unknown>, hasSource: boolean,
|
|
40
|
+
/** What was asked earlier in this session, oldest first. A few lines, not a
|
|
41
|
+
* transcript — it is the difference between understanding "a bit more" and
|
|
42
|
+
* inventing three categories of star that do not exist. */
|
|
43
|
+
history?: string[],
|
|
44
|
+
/** This turn is already an answer to a clarification. Asking again is a loop
|
|
45
|
+
* and the user has paid for it twice. */
|
|
46
|
+
alreadyAsked?: boolean,
|
|
47
|
+
/** A frame of the component as it renders NOW is attached to this call. */
|
|
48
|
+
hasImage?: boolean): string;
|
|
49
|
+
/** The brief, with its constraints attached, as the editing model sees it.
|
|
50
|
+
* Constraints ride here rather than in the system prompt for the same reason
|
|
51
|
+
* recipes do — they vary per turn, and a varying line invalidates the cached
|
|
52
|
+
* prefix for the whole file. */
|
|
53
|
+
export declare function intentToInstruction(intent: Intent): string;
|
|
54
|
+
export declare const deniesExistence: (question: string) => boolean;
|
|
55
|
+
export declare const promisesNothing: (brief: string) => boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The request names no thing to act on.
|
|
58
|
+
*
|
|
59
|
+
* History cannot rescue this and is what makes it dangerous: after a
|
|
60
|
+
* liquid-metal turn, "inc this" reads as obvious, and the agent duly raised
|
|
61
|
+
* flow speed, viscosity, iridescence AND shine — four knobs nobody named — for
|
|
62
|
+
* 20s and a rewrite. The previous turn is one candidate among everything on
|
|
63
|
+
* screen, so treating it as the antecedent is a guess dressed as context.
|
|
64
|
+
*
|
|
65
|
+
* A prompt rule for this was written first and did NOT hold: told plainly that
|
|
66
|
+
* history supplies degree and never subject, the agent guessed anyway. Hence a
|
|
67
|
+
* check, like every other guard here that survived contact.
|
|
68
|
+
*
|
|
69
|
+
* Deliberately narrow. It fires only when EVERY word is one of a small closed
|
|
70
|
+
* set, so "make it red" (red), "reduce the star size" (star, size) and
|
|
71
|
+
* "increase the number of bubbles" (number, bubbles) all pass untouched.
|
|
72
|
+
* Interrogating a clear request is the worse failure of the two.
|
|
73
|
+
*/
|
|
74
|
+
export declare function noSubject(ask: string): boolean;
|
|
75
|
+
/** Never throws, never returns null. A scaffold that cannot be read hands the
|
|
76
|
+
* user's own sentence straight through, which is exactly what the page did
|
|
77
|
+
* before this agent existed. */
|
|
78
|
+
export declare function parseIntent(raw: string, ask: string, hasSource: boolean): Intent;
|
|
79
|
+
/** The user answered a clarification. Fold it into the ask rather than starting
|
|
80
|
+
* a message thread — the turn stays single-shot, which is the whole design of
|
|
81
|
+
* this page. */
|
|
82
|
+
export declare function withAnswer(ask: string, question: string, answer: string): string;
|
|
83
|
+
export declare function buildPropSystem(entry: ComponentSpec, values: Record<string, unknown>, intent: Intent): string;
|
|
84
|
+
export declare function pinnedAtLimit(ask: string, intent: Intent, applied: Record<string, unknown>, props: Record<string, PropSpec>): string | null;
|
|
85
|
+
export declare function unwiredProps(source: string, names: string[]): string[];
|
|
86
|
+
export declare function partialNesting(source: string, declared: string[]): string[];
|
|
87
|
+
/** The correction for a partial nested override. Names the exact keys that
|
|
88
|
+
* would go undefined, because "declare them all" without the list invites the
|
|
89
|
+
* same three props back. */
|
|
90
|
+
export declare function completeNestingCorrection(source: string, prefixes: string[], declared: string[]): string;
|
|
91
|
+
export declare function settingsBags(props: Record<string, PropSpec>): string[];
|
|
92
|
+
/** The correction for a bundled prop. Names the dot-path form, because "split
|
|
93
|
+
* it up" leaves the model to invent a shape and it will invent this one
|
|
94
|
+
* again. */
|
|
95
|
+
export declare function unbundleCorrection(names: string[], props: Record<string, PropSpec>): string;
|
|
96
|
+
export type Fault = {
|
|
97
|
+
/** Handed to the editor on the retry. */
|
|
98
|
+
correction: string;
|
|
99
|
+
/** One line for the step trace. */
|
|
100
|
+
label: string;
|
|
101
|
+
/** For the verdict, so the turn card says what was rejected. */
|
|
102
|
+
failed: string[];
|
|
103
|
+
};
|
|
104
|
+
export type CandidateChecks = {
|
|
105
|
+
/** Errors thrown after mount. Pass `[]` if the host cannot observe them. */
|
|
106
|
+
threw: string[];
|
|
107
|
+
/** Declared props the file never reads. */
|
|
108
|
+
dead: string[];
|
|
109
|
+
/** Dot-path props covering only part of the object they nest into. */
|
|
110
|
+
partial: string[];
|
|
111
|
+
/** `json` props that are really a bag of settings. */
|
|
112
|
+
bagged: string[];
|
|
113
|
+
/** The specs this answer declared, for the corrections that quote them. */
|
|
114
|
+
declared: Record<string, PropSpec>;
|
|
115
|
+
/** The file itself, for the corrections that read it. */
|
|
116
|
+
code: string;
|
|
117
|
+
};
|
|
118
|
+
export declare function faultIn(c: CandidateChecks): Fault | null;
|
|
119
|
+
/** The correction for a file that compiled and then threw once it ran. Says
|
|
120
|
+
* where the gap is, because "fix the error" invites the model to re-read the
|
|
121
|
+
* code it already believes is correct. */
|
|
122
|
+
export declare function runtimeErrorCorrection(errors: string[]): string;
|
|
123
|
+
/** The correction for a rewrite that declared knobs it did not connect. Given
|
|
124
|
+
* to the editor verbatim, so it names the props and says what "wired" means —
|
|
125
|
+
* "use them" is the instruction it already thought it had followed. */
|
|
126
|
+
export declare function wireUpCorrection(names: string[]): string;
|
|
127
|
+
export declare function movedOnly(applied: Record<string, unknown>, current: Record<string, unknown>): Record<string, unknown>;
|
|
128
|
+
export declare function adoptRedeclared(existing: PropSpec, proposed: PropSpec): PropSpec | null;
|
|
129
|
+
export type Evidence = {
|
|
130
|
+
/** Both frames were captured and carry something. False disables every
|
|
131
|
+
* conclusion below — see `captureFrame` on why a capture can come back
|
|
132
|
+
* blank. */
|
|
133
|
+
ok: boolean;
|
|
134
|
+
paletteChanged: boolean;
|
|
135
|
+
before: string[];
|
|
136
|
+
after: string[];
|
|
137
|
+
};
|
|
138
|
+
export declare const NO_EVIDENCE: Evidence;
|
|
139
|
+
export declare function compareFrames(before: Extract | null, after: Extract | null): Evidence;
|
|
140
|
+
export declare function hardFail(intent: Intent, ev: Evidence): string | null;
|
|
141
|
+
export declare function buildCriticSystem(): string;
|
|
142
|
+
export declare function buildCriticUser(intent: Intent, changed: string, ev: Evidence,
|
|
143
|
+
/** A frame of the result is attached to this call. Changes what the critic
|
|
144
|
+
* can be asked for, so it changes what it is told. */
|
|
145
|
+
hasImage?: boolean): string;
|
|
146
|
+
/** Fail open. An unreadable verdict must not fail a turn the compile step
|
|
147
|
+
* already accepted — that would make the scaffold a way to lose answers that
|
|
148
|
+
* worked, which is worse than having no critic. */
|
|
149
|
+
export declare function parseVerdict(raw: string): Verdict;
|
|
150
|
+
/** The retry's instruction: the original brief, plus what went wrong. Not a
|
|
151
|
+
* conversation — the editing model gets one self-contained ask each time, the
|
|
152
|
+
* same as every other turn on this page. */
|
|
153
|
+
export declare function withCorrection(instruction: string, correction: string): string;
|
|
154
|
+
/** Did this retry do better than the last one? Two attempts that meet the same
|
|
155
|
+
* number of criteria are a loop, and a third call would buy the same answer a
|
|
156
|
+
* third time. */
|
|
157
|
+
export declare const improved: (now: Verdict, prev: Verdict | null) => boolean;
|
|
158
|
+
export declare function changeSummary(before: string, after: string): string;
|
|
159
|
+
/** Only what the props route can show the critic. The file did not move, so
|
|
160
|
+
* the diff IS the patch. */
|
|
161
|
+
export declare function patchSummary(applied: Record<string, unknown> | null, before: Record<string, unknown>, props: Record<string, PropSpec>): string;
|
|
162
|
+
//# sourceMappingURL=agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../../benchmark/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AA2B1C;8EAC8E;AAC9E,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEjD,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEvD,MAAM,MAAM,MAAM,GAAG;IACnB;2BACuB;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,gFAAgF;IAChF,WAAW,EAAE,MAAM,EAAE,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