@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.
Files changed (37) hide show
  1. package/dist/benchmark/agents.d.ts +162 -0
  2. package/dist/benchmark/agents.d.ts.map +1 -0
  3. package/dist/benchmark/agents.js +1187 -0
  4. package/dist/benchmark/agents.js.map +1 -0
  5. package/dist/benchmark/diff.d.ts +23 -0
  6. package/dist/benchmark/diff.d.ts.map +1 -0
  7. package/dist/benchmark/diff.js +117 -0
  8. package/dist/benchmark/diff.js.map +1 -0
  9. package/dist/benchmark/domain.d.ts +8 -0
  10. package/dist/benchmark/domain.d.ts.map +1 -0
  11. package/dist/benchmark/domain.js +322 -0
  12. package/dist/benchmark/domain.js.map +1 -0
  13. package/dist/benchmark/edit-pass.d.ts +38 -0
  14. package/dist/benchmark/edit-pass.d.ts.map +1 -0
  15. package/dist/benchmark/edit-pass.js +121 -0
  16. package/dist/benchmark/edit-pass.js.map +1 -0
  17. package/dist/benchmark/prompt.d.ts +128 -0
  18. package/dist/benchmark/prompt.d.ts.map +1 -0
  19. package/dist/benchmark/prompt.js +883 -0
  20. package/dist/benchmark/prompt.js.map +1 -0
  21. package/dist/benchmark/run-loop.d.ts +74 -0
  22. package/dist/benchmark/run-loop.d.ts.map +1 -0
  23. package/dist/benchmark/run-loop.js +138 -0
  24. package/dist/benchmark/run-loop.js.map +1 -0
  25. package/dist/benchmark/schema.d.ts +13 -0
  26. package/dist/benchmark/schema.d.ts.map +1 -0
  27. package/dist/benchmark/schema.js +63 -0
  28. package/dist/benchmark/schema.js.map +1 -0
  29. package/dist/benchmark/types.d.ts +113 -0
  30. package/dist/benchmark/types.d.ts.map +1 -0
  31. package/dist/benchmark/types.js +18 -0
  32. package/dist/benchmark/types.js.map +1 -0
  33. package/dist/packages/ai-engine/index.d.ts +13 -0
  34. package/dist/packages/ai-engine/index.d.ts.map +1 -0
  35. package/dist/packages/ai-engine/index.js +39 -0
  36. package/dist/packages/ai-engine/index.js.map +1 -0
  37. package/package.json +26 -0
@@ -0,0 +1,121 @@
1
+ import { buildEditRepairUser, buildEditSystem, buildUser, parseEdits, rewriteMaxTokens, sourceFromAnswer, tooBigToRewrite, unfence, wasCutOff, } from "./prompt.js";
2
+ /** Sum two calls into one row. Cost, tokens and time add; `ttftMs` stays the
3
+ * first call's, because time-to-first-token is a property of a request and
4
+ * adding two of them describes nothing. */
5
+ export function addRow(a, b) {
6
+ return {
7
+ ...b,
8
+ cost: (a.cost ?? 0) + (b.cost ?? 0),
9
+ promptTokens: (a.promptTokens ?? 0) + (b.promptTokens ?? 0),
10
+ completionTokens: (a.completionTokens ?? 0) + (b.completionTokens ?? 0),
11
+ totalMs: a.totalMs + b.totalMs,
12
+ ttftMs: a.ttftMs,
13
+ };
14
+ }
15
+ export async function editPass(opts, deps) {
16
+ const { component, instruction, source, needs, forceEdits } = opts;
17
+ const { call, compile, cancelled, report } = deps;
18
+ const editSystem = buildEditSystem(component, source, needs, forceEdits);
19
+ // The file, so a recipe can attach itself to what the component IS rather
20
+ // than only to what was asked — the user never says "shader".
21
+ const editUser = buildUser(instruction, source);
22
+ /* Scaled to the file, because the answer IS the file — the edit prompt asks
23
+ * for a complete rewrite. OpenRouter reserves max_tokens against the balance
24
+ * before the request runs, so this is not a formality: too high and a small
25
+ * balance 402s outright, too low and the answer stops mid-file and comes back
26
+ * as finishReason "length". */
27
+ const maxTokens = rewriteMaxTokens(source);
28
+ const endEdit = report?.("rewriting the file");
29
+ let row = await call({ system: editSystem, user: editUser, maxTokens });
30
+ let { body } = unfence(row.raw ?? "");
31
+ let { edits, props: declared } = parseEdits(body);
32
+ let patched = sourceFromAnswer(source, body);
33
+ let built = patched.ok
34
+ ? await compile(patched.code)
35
+ : { ok: false, error: patched.error };
36
+ endEdit?.({
37
+ status: built.ok ? "ok" : "fail",
38
+ detail: built.ok
39
+ ? `compiled${row.completionTokens ? ` · ${row.completionTokens} tokens out` : ""}`
40
+ : built.error,
41
+ cost: row.cost,
42
+ });
43
+ /* A truncated answer is not a broken one, and the difference decides whether
44
+ * a second call is worth buying.
45
+ *
46
+ * `finishReason: "length"` means the model stopped mid-file because it ran
47
+ * out of output budget — the source it produced is fine up to the cut. The
48
+ * ordinary repair sends the whole prompt back with "fix this syntax error",
49
+ * which asks for the same oversized file again and truncates again in the
50
+ * same place, at full price. Measured on a large component: 66s, a second
51
+ * call, and the same `Expected ")" but found end of file`.
52
+ *
53
+ * So say what actually happened. The file is too big for this model's output
54
+ * budget in one pass, and the answer is a bigger model or a smaller file —
55
+ * neither of which a repair round can reach. */
56
+ /* A truncated answer gets a DIFFERENT second call, not the usual repair.
57
+ *
58
+ * The ordinary repair re-sends the same prompt with "fix this syntax error",
59
+ * which asks for the same oversized file again and stops in the same place at
60
+ * the same price — measured at 113s on a 27KB file. Whether it truncates is
61
+ * not a function of size alone: the same file rewrites cleanly for one model
62
+ * and is cut off by another, so a threshold cannot decide it up front and
63
+ * only the failed answer can.
64
+ *
65
+ * So on a cut-off, ask again in SEARCH/REPLACE form, where the output is the
66
+ * size of the CHANGE rather than the size of the file. Same budget, one call,
67
+ * and it is the shape that was always going to work. */
68
+ if (!built.ok && wasCutOff(row.finishReason, built.error) && !cancelled?.()) {
69
+ const endAgain = report?.("editing it in place instead");
70
+ const again = await call({
71
+ system: buildEditSystem(component, source, needs, true),
72
+ user: editUser,
73
+ maxTokens,
74
+ });
75
+ row = addRow(row, again);
76
+ ({ body } = unfence(again.raw ?? ""));
77
+ ({ edits, props: declared } = parseEdits(body));
78
+ patched = sourceFromAnswer(source, body);
79
+ built = patched.ok
80
+ ? await compile(patched.code)
81
+ : { ok: false, error: patched.error };
82
+ endAgain?.({
83
+ status: built.ok ? "ok" : "fail",
84
+ detail: built.ok
85
+ ? `compiled${again.completionTokens ? ` · ${again.completionTokens} tokens out` : ""}`
86
+ : built.error,
87
+ cost: again.cost,
88
+ });
89
+ if (built.ok)
90
+ return { row, edits, declared, patched, built };
91
+ }
92
+ if (!built.ok && !cancelled?.()) {
93
+ const endRepair = report?.("repairing it");
94
+ const repair = await call({
95
+ messages: [
96
+ { role: "system", content: editSystem },
97
+ { role: "user", content: editUser },
98
+ { role: "assistant", content: row.raw ?? "" },
99
+ {
100
+ role: "user",
101
+ content: buildEditRepairUser(built.error, source, forceEdits || tooBigToRewrite(source)),
102
+ },
103
+ ],
104
+ maxTokens,
105
+ });
106
+ row = addRow(row, repair);
107
+ ({ body } = unfence(repair.raw ?? ""));
108
+ ({ edits, props: declared } = parseEdits(body));
109
+ patched = sourceFromAnswer(source, body);
110
+ built = patched.ok
111
+ ? await compile(patched.code)
112
+ : { ok: false, error: patched.error };
113
+ endRepair?.({
114
+ status: built.ok ? "ok" : "fail",
115
+ detail: built.ok ? "compiled" : built.error,
116
+ cost: repair.cost,
117
+ });
118
+ }
119
+ return { row, edits, declared, patched, built };
120
+ }
121
+ //# sourceMappingURL=edit-pass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit-pass.js","sourceRoot":"","sources":["../../../../benchmark/edit-pass.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,OAAO,EACP,SAAS,GAGV,MAAM,aAAa,CAAC;AA0CrB;;4CAE4C;AAC5C,MAAM,UAAU,MAAM,CAAC,CAAS,EAAE,CAAS;IACzC,OAAO;QACL,GAAG,CAAC;QACJ,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;QACnC,YAAY,EAAE,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC;QAC3D,gBAAgB,EAAE,CAAC,CAAC,CAAC,gBAAgB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,gBAAgB,IAA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AAC,CAAC;QAC1B,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;QACvC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QAChD,OAAO,GAAG,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACzC,KAAK,GAAG,OAAO,CAAC,EAAE;YAChB,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YAC7B,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;QACxC,SAAS,EAAE,CAAC;YACV,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;YAChC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK;YAC3C,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAClD,CAAC"}
@@ -0,0 +1,128 @@
1
+ import type { ComponentSpec, PropSpec } from "./types.ts";
2
+ export declare function buildSystem(entry: ComponentSpec, values: Record<string, unknown>): string;
3
+ export declare const PROPS_MARKER = "///NEW-PROPS";
4
+ export declare const SEARCH = "<<<<<<< SEARCH";
5
+ export declare const DIVIDER = "=======";
6
+ export declare const REPLACE = ">>>>>>> REPLACE";
7
+ /** Output ceiling for a whole-file rewrite. File size is the floor; the
8
+ * multiplier is reasoning headroom. Capped at 32k so a small balance does
9
+ * not 402 on the reservation. */
10
+ export declare function rewriteMaxTokens(source: string): number;
11
+ export declare function tooBigToRewrite(source: string): boolean;
12
+ /** Did this answer stop mid-file rather than finish? */
13
+ export declare function wasCutOff(finishReason: string | null, error?: string): boolean;
14
+ export declare function buildEditSystem(name: string, source: string, needs?: string[],
15
+ /** Force in-place edits — used after a rewrite came back truncated. */
16
+ forceEdits?: boolean): string;
17
+ export declare function buildUser(instruction: string, source?: string): string;
18
+ /** True when every `needs` entry is just an existing knob to turn.
19
+ * "color - make it red" is that. "color - support for a gradient" is not:
20
+ * `color` exists, the gradient does not, and treating it as a prop patch
21
+ * is what blocked adding the missing look. */
22
+ export declare function needsAlreadyInSchema(needs: string[] | undefined, props: Record<string, PropSpec>): boolean;
23
+ /** When a rewrite adds a colour-list prop defaulted to `["#FFFFFF"]`, the
24
+ * preview stays the old burst. Seed the session (and the spec default) with
25
+ * the current colour plus two more so the asked look is on screen without
26
+ * another turn. */
27
+ export declare function seedVisibleNewProps(ask: string, current: Record<string, unknown>, fresh: Record<string, PropSpec>): {
28
+ props: Record<string, PropSpec>;
29
+ values: Record<string, unknown>;
30
+ };
31
+ /** Follow-up after the rewritten file fails to compile. One retry. */
32
+ export declare function buildEditRepairUser(error: string, source: string,
33
+ /** Keep the answer in search/replace form — see below. */
34
+ edits?: boolean): string;
35
+ export declare function repairJson(text: string): string;
36
+ export type PropsBlock = {
37
+ ok: true;
38
+ json: string;
39
+ } | {
40
+ ok: false;
41
+ error: string;
42
+ };
43
+ /**
44
+ * Turn whatever the model emitted after ///NEW-PROPS into a name -> spec object.
45
+ *
46
+ * Three real failures, all measured, all repaired here rather than lost:
47
+ *
48
+ * - JS instead of JSON: single quotes, unquoted keys, trailing commas.
49
+ * - Unbalanced braces, from a spec left open.
50
+ * - A sibling prop nested INSIDE another prop's spec. `colorScheme` came back
51
+ * carrying `colors` as one of its own fields; a spec cannot contain a spec,
52
+ * so a nested one is unambiguously a sibling that was mis-nested.
53
+ *
54
+ * A bare spec with no prop name is refused, not guessed: the name is the one
55
+ * piece of information that cannot be recovered from the block. Whatever comes
56
+ * out still goes through validateSchema, which is what actually decides.
57
+ */
58
+ export declare function repairPropsBlock(text: string): PropsBlock;
59
+ export type Edit = {
60
+ search: string;
61
+ replace: string;
62
+ };
63
+ /** Pull the edit blocks and the optional new-prop JSON out of an answer. */
64
+ export declare function parseEdits(body: string): {
65
+ edits: Edit[];
66
+ props: string | null;
67
+ };
68
+ export type ApplyResult = {
69
+ ok: true;
70
+ code: string;
71
+ applied: number;
72
+ } | {
73
+ ok: false;
74
+ error: string;
75
+ };
76
+ /**
77
+ * Apply edit blocks to a source file.
78
+ *
79
+ * Exact match first. Failing that, two fallbacks, both unique-or-fail:
80
+ * 1. each line trimmed — recovers the wrong-indent copy.
81
+ * 2. whitespace / trailing `;` / trailing `...` stripped — recovers
82
+ * `createLinearGradient(0,0,X,0)` vs `(0, 0, X, 0)` and a SEARCH that
83
+ * ends in an ellipsis. Anything looser would start matching code the
84
+ * model did not mean, and a wrong edit that compiles is the worst outcome
85
+ * available here — worse than a failed turn, because nobody sees it.
86
+ *
87
+ * Never partially applies. An edit that misses fails the whole turn, naming
88
+ * which block and why.
89
+ */
90
+ export declare function applyEdits(source: string, edits: Edit[]): ApplyResult;
91
+ /** Source from an edit-pass answer. SEARCH/REPLACE still applies when that is
92
+ * the shape of the answer; otherwise the body is the new file. An unchanged
93
+ * copy of the input is a miss — the preview would not move. */
94
+ export declare function sourceFromAnswer(previous: string, body: string): ApplyResult;
95
+ /** Colour asks that only add `color2` / a midpoint and leave every paint
96
+ * line on the old `cStar` compile and "succeed" — the preview does not
97
+ * move. Fail those so Iterate can repair instead of showing a new knob
98
+ * that does nothing. */
99
+ export declare function withColourDrawCheck(ask: string, before: string, result: ApplyResult): ApplyResult;
100
+ export declare function unfence(raw: string): {
101
+ body: string;
102
+ fenced: boolean;
103
+ };
104
+ export type Validity = {
105
+ json: boolean;
106
+ /** every key exists in the schema */
107
+ schema: boolean;
108
+ /** every value satisfies its type / range / enum */
109
+ types: boolean;
110
+ /** model correctly declined an out-of-scope request */
111
+ refused: boolean;
112
+ /** Props the model says would be needed to satisfy it. Only on a refusal. */
113
+ needs?: string[];
114
+ patch: Record<string, unknown> | null;
115
+ issues: string[];
116
+ };
117
+ export declare function validate(raw: string, schema: Record<string, PropSpec>): Validity;
118
+ /** The diff view: how the component would be written before and after.
119
+ * Dot-paths are re-nested so this reads as real JSX, and key order comes
120
+ * from the schema so before/after stay line-aligned. */
121
+ export declare function toJsx(name: string, flat: Record<string, unknown>): string;
122
+ export declare const isHtmlDoc: (source: string) => boolean;
123
+ /** Turn one: there is no file yet, so the model writes one. Every line of this
124
+ * prompt is stable, which makes the whole system block cacheable across every
125
+ * section a model is ever asked for. */
126
+ export declare function buildSectionSystem(): string;
127
+ export declare function buildSectionEditSystem(source: string): string;
128
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../benchmark/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAiB1D,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,UAkChF;AAOD,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,eAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,OAAO,oBAAoB,CAAC;AAEzC;;kCAEkC;AAClC,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,UAG9C;AAgBD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED,wDAAwD;AACxD,wBAAgB,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAM9E;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE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