@xom11/whiteboard 0.28.0 → 0.30.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/ai.d.mts +250 -277
- package/dist/ai.d.ts +250 -277
- package/dist/ai.js +6045 -7459
- package/dist/ai.js.map +1 -1
- package/dist/ai.mjs +4806 -5457
- package/dist/ai.mjs.map +1 -1
- package/dist/catalog.json +2 -2
- package/dist/chunk-QK6OVDLC.mjs +103 -0
- package/dist/chunk-QK6OVDLC.mjs.map +1 -0
- package/dist/{chunk-AJAHD35N.mjs → chunk-SF3U7ZF4.mjs} +3 -32
- package/dist/chunk-SF3U7ZF4.mjs.map +1 -0
- package/dist/{chunk-QCZVFEN4.mjs → chunk-XVVLT6B3.mjs} +3 -3
- package/dist/{chunk-QCZVFEN4.mjs.map → chunk-XVVLT6B3.mjs.map} +1 -1
- package/dist/geometry-2d.d.mts +1 -2
- package/dist/geometry-2d.d.ts +1 -2
- package/dist/geometry-2d.js +1457 -3832
- package/dist/geometry-2d.js.map +1 -1
- package/dist/geometry-2d.mjs +1 -1
- package/dist/geometry-3d.d.mts +1 -2
- package/dist/geometry-3d.d.ts +1 -2
- package/dist/graph-2d.d.mts +1 -2
- package/dist/graph-2d.d.ts +1 -2
- package/dist/handleExtractProblem-BrDY9ifM.d.mts +58 -0
- package/dist/handleExtractProblem-BrDY9ifM.d.ts +58 -0
- package/dist/{host-4P766V4J.mjs → host-3UFGFMJ2.mjs} +45 -139
- package/dist/host-3UFGFMJ2.mjs.map +1 -0
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.js +1487 -3862
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/latex.d.mts +1 -2
- package/dist/latex.d.ts +1 -2
- package/dist/{types-BHYC2Fiw.d.mts → types-C3FjpoUi.d.mts} +1 -232
- package/dist/{types-BHYC2Fiw.d.ts → types-C3FjpoUi.d.ts} +1 -232
- package/package.json +1 -8
- package/dist/chunk-AJAHD35N.mjs.map +0 -1
- package/dist/chunk-T3SOHYB2.mjs +0 -851
- package/dist/chunk-T3SOHYB2.mjs.map +0 -1
- package/dist/handleExtractProblem-C-U5KluK.d.mts +0 -158
- package/dist/handleExtractProblem-C-U5KluK.d.ts +0 -158
- package/dist/host-4P766V4J.mjs.map +0 -1
package/dist/ai.d.mts
CHANGED
|
@@ -1,10 +1,235 @@
|
|
|
1
|
-
import { c as State,
|
|
1
|
+
import { c as State, b as AiFigureUiResult } from './types-C3FjpoUi.mjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { I as ImagePart } from './handleExtractProblem-BrDY9ifM.mjs';
|
|
4
|
+
export { a as ExtractProblemOptions, b as ExtractProblemOutcome, E as ExtractUiResult, H as HandleExtractProblemOptions, e as extractProblemFromImage, h as handleExtractProblem } from './handleExtractProblem-BrDY9ifM.mjs';
|
|
5
5
|
import 'react';
|
|
6
6
|
import '@excalidraw/excalidraw/element/types';
|
|
7
7
|
|
|
8
|
+
declare const NameZ: z.ZodString;
|
|
9
|
+
|
|
10
|
+
type Name = z.infer<typeof NameZ>;
|
|
11
|
+
type DslDistanceSpec = {
|
|
12
|
+
kind: 'circleRadius';
|
|
13
|
+
circle: Name;
|
|
14
|
+
scale?: number;
|
|
15
|
+
offset?: number;
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'segmentLength';
|
|
18
|
+
p1: Name;
|
|
19
|
+
p2: Name;
|
|
20
|
+
scale?: number;
|
|
21
|
+
offset?: number;
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'literal';
|
|
24
|
+
value: number;
|
|
25
|
+
scale?: number;
|
|
26
|
+
offset?: number;
|
|
27
|
+
};
|
|
28
|
+
type DslPointT = {
|
|
29
|
+
name: Name;
|
|
30
|
+
kind: 'free';
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
} | {
|
|
34
|
+
name: Name;
|
|
35
|
+
kind: 'midpoint';
|
|
36
|
+
p1: Name;
|
|
37
|
+
p2: Name;
|
|
38
|
+
visible?: boolean;
|
|
39
|
+
} | {
|
|
40
|
+
name: Name;
|
|
41
|
+
kind: 'onSegment';
|
|
42
|
+
segmentId: Name;
|
|
43
|
+
t: number;
|
|
44
|
+
} | {
|
|
45
|
+
name: Name;
|
|
46
|
+
kind: 'onLine';
|
|
47
|
+
lineId: Name;
|
|
48
|
+
t: number;
|
|
49
|
+
} | {
|
|
50
|
+
name: Name;
|
|
51
|
+
kind: 'onCircle';
|
|
52
|
+
circleId: Name;
|
|
53
|
+
theta: number;
|
|
54
|
+
} | {
|
|
55
|
+
name: Name;
|
|
56
|
+
kind: 'perpFoot';
|
|
57
|
+
from: Name;
|
|
58
|
+
onLine: Name;
|
|
59
|
+
} | {
|
|
60
|
+
name: Name;
|
|
61
|
+
kind: 'circumcenter';
|
|
62
|
+
vertices: [Name, Name, Name];
|
|
63
|
+
} | {
|
|
64
|
+
name: Name;
|
|
65
|
+
kind: 'incenter';
|
|
66
|
+
vertices: [Name, Name, Name];
|
|
67
|
+
} | {
|
|
68
|
+
name: Name;
|
|
69
|
+
kind: 'centroid';
|
|
70
|
+
vertices: [Name, Name, Name];
|
|
71
|
+
} | {
|
|
72
|
+
name: Name;
|
|
73
|
+
kind: 'orthocenter';
|
|
74
|
+
vertices: [Name, Name, Name];
|
|
75
|
+
} | {
|
|
76
|
+
name: Name;
|
|
77
|
+
kind: 'intersection';
|
|
78
|
+
ref1: Name;
|
|
79
|
+
ref2: Name;
|
|
80
|
+
branch?: 0 | 1;
|
|
81
|
+
} | {
|
|
82
|
+
name: Name;
|
|
83
|
+
kind: 'secondIntersection';
|
|
84
|
+
line: Name;
|
|
85
|
+
circle: Name;
|
|
86
|
+
other: Name;
|
|
87
|
+
} | {
|
|
88
|
+
name: Name;
|
|
89
|
+
kind: 'circleIntersection';
|
|
90
|
+
c1: Name;
|
|
91
|
+
c2: Name;
|
|
92
|
+
which: 0 | 1;
|
|
93
|
+
} | {
|
|
94
|
+
name: Name;
|
|
95
|
+
kind: 'circleSecondIntersection';
|
|
96
|
+
c1: Name;
|
|
97
|
+
c2: Name;
|
|
98
|
+
exclude: Name;
|
|
99
|
+
} | {
|
|
100
|
+
name: Name;
|
|
101
|
+
kind: 'tangencyPoint';
|
|
102
|
+
circle: Name;
|
|
103
|
+
onLine: Name;
|
|
104
|
+
} | {
|
|
105
|
+
name: Name;
|
|
106
|
+
kind: 'tangentPointExt';
|
|
107
|
+
from: Name;
|
|
108
|
+
circle: Name;
|
|
109
|
+
which: 0 | 1;
|
|
110
|
+
} | {
|
|
111
|
+
name: Name;
|
|
112
|
+
kind: 'arcMidpoint';
|
|
113
|
+
circle: Name;
|
|
114
|
+
a: Name;
|
|
115
|
+
b: Name;
|
|
116
|
+
notContaining: Name;
|
|
117
|
+
} | {
|
|
118
|
+
name: Name;
|
|
119
|
+
kind: 'excenter';
|
|
120
|
+
vertices: [Name, Name, Name];
|
|
121
|
+
opposite: Name;
|
|
122
|
+
} | {
|
|
123
|
+
name: Name;
|
|
124
|
+
kind: 'reflectPoint';
|
|
125
|
+
of: Name;
|
|
126
|
+
through: Name;
|
|
127
|
+
} | {
|
|
128
|
+
name: Name;
|
|
129
|
+
kind: 'reflectLine';
|
|
130
|
+
of: Name;
|
|
131
|
+
through: Name;
|
|
132
|
+
} | {
|
|
133
|
+
name: Name;
|
|
134
|
+
kind: 'pointAtDistance';
|
|
135
|
+
from: Name;
|
|
136
|
+
through: Name;
|
|
137
|
+
distance: DslDistanceSpec;
|
|
138
|
+
};
|
|
139
|
+
type DslShapeT = {
|
|
140
|
+
name: Name;
|
|
141
|
+
kind: 'segment';
|
|
142
|
+
p1: Name;
|
|
143
|
+
p2: Name;
|
|
144
|
+
} | {
|
|
145
|
+
name: Name;
|
|
146
|
+
kind: 'line';
|
|
147
|
+
p1: Name;
|
|
148
|
+
p2: Name;
|
|
149
|
+
} | {
|
|
150
|
+
name: Name;
|
|
151
|
+
kind: 'ray';
|
|
152
|
+
origin: Name;
|
|
153
|
+
through: Name;
|
|
154
|
+
} | {
|
|
155
|
+
name: Name;
|
|
156
|
+
kind: 'polygon';
|
|
157
|
+
vertices: Name[];
|
|
158
|
+
} | {
|
|
159
|
+
name: Name;
|
|
160
|
+
kind: 'perpendicular';
|
|
161
|
+
throughPoint: Name;
|
|
162
|
+
toLine: Name;
|
|
163
|
+
} | {
|
|
164
|
+
name: Name;
|
|
165
|
+
kind: 'parallel';
|
|
166
|
+
throughPoint: Name;
|
|
167
|
+
toLine: Name;
|
|
168
|
+
} | {
|
|
169
|
+
name: Name;
|
|
170
|
+
kind: 'perpBisector';
|
|
171
|
+
p1: Name;
|
|
172
|
+
p2: Name;
|
|
173
|
+
} | {
|
|
174
|
+
name: Name;
|
|
175
|
+
kind: 'angleBisector';
|
|
176
|
+
p1: Name;
|
|
177
|
+
vertex: Name;
|
|
178
|
+
p2: Name;
|
|
179
|
+
} | {
|
|
180
|
+
name: Name;
|
|
181
|
+
kind: 'lineThrough';
|
|
182
|
+
points: Name[];
|
|
183
|
+
} | {
|
|
184
|
+
name: Name;
|
|
185
|
+
kind: 'radicalAxis';
|
|
186
|
+
circle1: Name;
|
|
187
|
+
circle2: Name;
|
|
188
|
+
} | {
|
|
189
|
+
name: Name;
|
|
190
|
+
kind: 'tangent';
|
|
191
|
+
throughPoint: Name;
|
|
192
|
+
toCircle: Name;
|
|
193
|
+
branch?: 0 | 1 | 'on';
|
|
194
|
+
} | {
|
|
195
|
+
name: Name;
|
|
196
|
+
kind: 'circleCP';
|
|
197
|
+
center: Name;
|
|
198
|
+
surfacePoint: Name;
|
|
199
|
+
visible?: boolean;
|
|
200
|
+
} | {
|
|
201
|
+
name: Name;
|
|
202
|
+
kind: 'circle3';
|
|
203
|
+
p1: Name;
|
|
204
|
+
p2: Name;
|
|
205
|
+
p3: Name;
|
|
206
|
+
} | {
|
|
207
|
+
name: Name;
|
|
208
|
+
kind: 'circleDiameter';
|
|
209
|
+
p1: Name;
|
|
210
|
+
p2: Name;
|
|
211
|
+
visible?: boolean;
|
|
212
|
+
} | {
|
|
213
|
+
name: Name;
|
|
214
|
+
kind: 'circleCR';
|
|
215
|
+
center: Name;
|
|
216
|
+
radius: number;
|
|
217
|
+
} | {
|
|
218
|
+
name: Name;
|
|
219
|
+
kind: 'incircle';
|
|
220
|
+
vertices: [Name, Name, Name];
|
|
221
|
+
} | {
|
|
222
|
+
name: Name;
|
|
223
|
+
kind: 'excircle';
|
|
224
|
+
vertices: [Name, Name, Name];
|
|
225
|
+
opposite: Name;
|
|
226
|
+
};
|
|
227
|
+
type DslInputT = {
|
|
228
|
+
version: 1;
|
|
229
|
+
points: DslPointT[];
|
|
230
|
+
shapes: DslShapeT[];
|
|
231
|
+
};
|
|
232
|
+
|
|
8
233
|
type TranspileErrorCode = 'SCHEMA' | 'DUPLICATE_NAME' | 'UNKNOWN_REF' | 'KIND_MISMATCH' | 'CYCLE';
|
|
9
234
|
interface TranspileError {
|
|
10
235
|
code: TranspileErrorCode;
|
|
@@ -20,39 +245,6 @@ type TranspileResult = {
|
|
|
20
245
|
errors: TranspileError[];
|
|
21
246
|
};
|
|
22
247
|
|
|
23
|
-
interface AnthropicProviderOptions {
|
|
24
|
-
apiKey: string;
|
|
25
|
-
/** Cache system prompt qua Anthropic prompt-caching (mặc định bật). */
|
|
26
|
-
enableCaching?: boolean;
|
|
27
|
-
}
|
|
28
|
-
declare class AnthropicProvider implements AIProvider {
|
|
29
|
-
private readonly opts;
|
|
30
|
-
readonly name = "anthropic";
|
|
31
|
-
readonly defaultModel = "claude-opus-4-7";
|
|
32
|
-
constructor(opts: AnthropicProviderOptions);
|
|
33
|
-
call(req: ProviderRequest): Promise<ProviderOutput>;
|
|
34
|
-
extractText(req: VisionRequest): Promise<ProviderOutput>;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface OllamaProviderOptions {
|
|
38
|
-
/** Endpoint base URL, default http://localhost:11434. */
|
|
39
|
-
baseUrl?: string;
|
|
40
|
-
/** Default model id nếu request không truyền. */
|
|
41
|
-
defaultModel?: string;
|
|
42
|
-
/** Custom fetch impl (dùng cho test mock). */
|
|
43
|
-
fetchImpl?: typeof fetch;
|
|
44
|
-
}
|
|
45
|
-
declare class OllamaProvider implements AIProvider {
|
|
46
|
-
readonly name = "ollama";
|
|
47
|
-
readonly defaultModel: string;
|
|
48
|
-
private readonly baseUrl;
|
|
49
|
-
private readonly fetchImpl;
|
|
50
|
-
constructor(opts?: OllamaProviderOptions);
|
|
51
|
-
private resolveFetch;
|
|
52
|
-
call(req: ProviderRequest): Promise<ProviderOutput>;
|
|
53
|
-
extractText(req: VisionRequest): Promise<ProviderOutput>;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
248
|
declare const DrawShapeIntentZ: z.ZodObject<{
|
|
57
249
|
op: z.ZodLiteral<"draw-shape">;
|
|
58
250
|
shape: z.ZodEnum<["triangle", "square", "rectangle", "rhombus", "trapezoid", "parallelogram", "quadrilateral"]>;
|
|
@@ -2886,23 +3078,8 @@ interface VerifyReport {
|
|
|
2886
3078
|
declare function compareIntents(expected: readonly IntentT[], actual: readonly IntentT[]): VerifyReport;
|
|
2887
3079
|
declare function verifyGeometry(intents: readonly IntentT[], dsl: DslInputT): VerifyReport;
|
|
2888
3080
|
|
|
2889
|
-
interface GenerateIntentOptions
|
|
2890
|
-
model?: string;
|
|
2891
|
-
maxTokens?: number;
|
|
3081
|
+
interface GenerateIntentOptions {
|
|
2892
3082
|
signal?: AbortSignal;
|
|
2893
|
-
/**
|
|
2894
|
-
* Track A deterministic-first (mặc định bật). Thử rule engine trước; chỉ gọi
|
|
2895
|
-
* LLM (Track B) khi deterministic không phủ đủ / không dựng được. Đặt false để
|
|
2896
|
-
* ép luôn dùng LLM (vd so sánh eval, debug).
|
|
2897
|
-
*/
|
|
2898
|
-
useDeterministic?: boolean;
|
|
2899
|
-
/**
|
|
2900
|
-
* CHỈ deterministic — KHÔNG fallback LLM. Track A miss → trả failure
|
|
2901
|
-
* `deterministic_miss` (kèm lý do) thay vì gọi Track B. Dùng khi tối ưu rule
|
|
2902
|
-
* base: muốn THẤY đề nào rule chưa phủ (không tốn token, không che lấp gap).
|
|
2903
|
-
* Ưu tiên hơn `useDeterministic` (true ⇒ luôn chạy Track A, không bao giờ LLM).
|
|
2904
|
-
*/
|
|
2905
|
-
deterministicOnly?: boolean;
|
|
2906
3083
|
}
|
|
2907
3084
|
interface IntentTokenUsage {
|
|
2908
3085
|
inputTokens: number;
|
|
@@ -2923,7 +3100,7 @@ interface IntentSuccessResult {
|
|
|
2923
3100
|
}
|
|
2924
3101
|
interface IntentFailureResult {
|
|
2925
3102
|
ok: false;
|
|
2926
|
-
reason: '
|
|
3103
|
+
reason: 'builder_error' | 'transpile_error' | 'verify_error' | 'deterministic_miss';
|
|
2927
3104
|
message: string;
|
|
2928
3105
|
intents?: readonly IntentT[];
|
|
2929
3106
|
dsl?: ReturnType<typeof intentsToDsl>;
|
|
@@ -2931,7 +3108,7 @@ interface IntentFailureResult {
|
|
|
2931
3108
|
provider?: string;
|
|
2932
3109
|
}
|
|
2933
3110
|
type IntentGenerateResult = IntentSuccessResult | IntentFailureResult;
|
|
2934
|
-
declare function generateFigureIntent(problem: string,
|
|
3111
|
+
declare function generateFigureIntent(problem: string, _opts?: GenerateIntentOptions): Promise<IntentGenerateResult>;
|
|
2935
3112
|
|
|
2936
3113
|
interface HandleGenerateFigureInput {
|
|
2937
3114
|
/** Đề bài tiếng Việt từ teacher. */
|
|
@@ -2949,7 +3126,8 @@ interface HandleGenerateFigureOptions extends GenerateIntentOptions {
|
|
|
2949
3126
|
onResult?: (result: IntentGenerateResult, attempt: number) => void;
|
|
2950
3127
|
/**
|
|
2951
3128
|
* Số attempt tối đa khi build error (transpile/builder). Default 2 (1 retry).
|
|
2952
|
-
*
|
|
3129
|
+
* Rule base deterministic → retry hiếm khi đổi kết quả, giữ để tương thích
|
|
3130
|
+
* contract cũ. Clamp [1,5].
|
|
2953
3131
|
*/
|
|
2954
3132
|
maxAttempts?: number;
|
|
2955
3133
|
}
|
|
@@ -2957,12 +3135,11 @@ interface HandleGenerateFigureOptions extends GenerateIntentOptions {
|
|
|
2957
3135
|
* Gọi rule-engine intent pipeline và trả về `AiFigureUiResult` mà
|
|
2958
3136
|
* `<Whiteboard generateGeometryFigure>` chấp nhận trực tiếp.
|
|
2959
3137
|
*
|
|
2960
|
-
*
|
|
2961
|
-
*
|
|
3138
|
+
* Deterministic rule base chạy trong `generateFigureIntent` — đề dễ→trung bình
|
|
3139
|
+
* dựng KHÔNG tốn token. Miss → `deterministic_miss` (KHÔNG LLM fallback).
|
|
2962
3140
|
*
|
|
2963
|
-
* Auto-retry: chỉ retry khi `transpile_error`/`builder_error
|
|
2964
|
-
*
|
|
2965
|
-
* `refused` (cố ý), `parse_error` (sai schema), `provider_error` (network/config).
|
|
3141
|
+
* Auto-retry: chỉ retry khi `transpile_error`/`builder_error`. KHÔNG retry
|
|
3142
|
+
* `deterministic_miss` (rule base ổn định, retry vô nghĩa).
|
|
2966
3143
|
*
|
|
2967
3144
|
* Server-side caller giữ `IntentGenerateResult` đầy đủ qua `onResult` cho
|
|
2968
3145
|
* telemetry/logging.
|
|
@@ -3071,187 +3248,6 @@ declare function envelopeJsonSchema(): Record<string, unknown>;
|
|
|
3071
3248
|
/** Helper: ép envelope build hợp lệ về DslInputT (sau khi đã validate). */
|
|
3072
3249
|
declare function envelopeBuildDsl(env: FigureEnvelopeT): DslInputT;
|
|
3073
3250
|
|
|
3074
|
-
interface GenerateDeltaOptions extends SelectProviderOptions {
|
|
3075
|
-
model?: string;
|
|
3076
|
-
maxTokens?: number;
|
|
3077
|
-
signal?: AbortSignal;
|
|
3078
|
-
maxAttempts?: number;
|
|
3079
|
-
}
|
|
3080
|
-
interface TokenUsage {
|
|
3081
|
-
inputTokens: number;
|
|
3082
|
-
outputTokens: number;
|
|
3083
|
-
cacheReadTokens: number;
|
|
3084
|
-
cacheCreationTokens: number;
|
|
3085
|
-
}
|
|
3086
|
-
type GenerateDeltaResult = {
|
|
3087
|
-
ok: true;
|
|
3088
|
-
state: State;
|
|
3089
|
-
mergedDsl: DslInputT;
|
|
3090
|
-
mode: 'add' | 'replace';
|
|
3091
|
-
usage: TokenUsage;
|
|
3092
|
-
provider: string;
|
|
3093
|
-
} | {
|
|
3094
|
-
ok: false;
|
|
3095
|
-
reason: 'refused';
|
|
3096
|
-
message: string;
|
|
3097
|
-
usage?: TokenUsage;
|
|
3098
|
-
provider?: string;
|
|
3099
|
-
} | {
|
|
3100
|
-
ok: false;
|
|
3101
|
-
reason: 'parse_error';
|
|
3102
|
-
message: string;
|
|
3103
|
-
raw?: unknown;
|
|
3104
|
-
usage?: TokenUsage;
|
|
3105
|
-
provider?: string;
|
|
3106
|
-
} | {
|
|
3107
|
-
ok: false;
|
|
3108
|
-
reason: 'transpile_error';
|
|
3109
|
-
message: string;
|
|
3110
|
-
errors: TranspileError[];
|
|
3111
|
-
dsl: unknown;
|
|
3112
|
-
usage?: TokenUsage;
|
|
3113
|
-
provider?: string;
|
|
3114
|
-
} | {
|
|
3115
|
-
ok: false;
|
|
3116
|
-
reason: 'name_collision';
|
|
3117
|
-
message: string;
|
|
3118
|
-
collisions: string[];
|
|
3119
|
-
errors: TranspileError[];
|
|
3120
|
-
dsl: unknown;
|
|
3121
|
-
usage?: TokenUsage;
|
|
3122
|
-
provider?: string;
|
|
3123
|
-
} | {
|
|
3124
|
-
ok: false;
|
|
3125
|
-
reason: 'unresolved_ref';
|
|
3126
|
-
message: string;
|
|
3127
|
-
refs: string[];
|
|
3128
|
-
errors: TranspileError[];
|
|
3129
|
-
dsl: unknown;
|
|
3130
|
-
usage?: TokenUsage;
|
|
3131
|
-
provider?: string;
|
|
3132
|
-
} | {
|
|
3133
|
-
ok: false;
|
|
3134
|
-
reason: 'api_error';
|
|
3135
|
-
message: string;
|
|
3136
|
-
status?: number;
|
|
3137
|
-
provider?: string;
|
|
3138
|
-
};
|
|
3139
|
-
interface GenerateFigureDeltaInput {
|
|
3140
|
-
problem: string;
|
|
3141
|
-
currentDsl: DslInputT;
|
|
3142
|
-
}
|
|
3143
|
-
declare function generateFigureDelta(input: GenerateFigureDeltaInput, opts?: GenerateDeltaOptions): Promise<GenerateDeltaResult>;
|
|
3144
|
-
|
|
3145
|
-
interface HandleGenerateFigureDeltaInput {
|
|
3146
|
-
problem: string;
|
|
3147
|
-
currentDsl: DslInputT;
|
|
3148
|
-
}
|
|
3149
|
-
interface HandleGenerateFigureDeltaOptions extends GenerateDeltaOptions {
|
|
3150
|
-
onResult?: (result: GenerateDeltaResult, attempt: number) => void;
|
|
3151
|
-
maxAttempts?: number;
|
|
3152
|
-
}
|
|
3153
|
-
declare function handleGenerateFigureDelta(input: HandleGenerateFigureDeltaInput, opts?: HandleGenerateFigureDeltaOptions): Promise<AiFigureUiResult>;
|
|
3154
|
-
|
|
3155
|
-
declare const FigureRefineEnvelopeZ: z.ZodEffects<z.ZodObject<{
|
|
3156
|
-
decision: z.ZodEnum<["add", "replace", "refuse"]>;
|
|
3157
|
-
figure: z.ZodOptional<z.ZodObject<{
|
|
3158
|
-
version: z.ZodLiteral<1>;
|
|
3159
|
-
points: z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<any, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
3160
|
-
[x: string]: any;
|
|
3161
|
-
}, {
|
|
3162
|
-
[x: string]: any;
|
|
3163
|
-
}>, z.ZodObject<any, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
3164
|
-
[x: string]: any;
|
|
3165
|
-
}, {
|
|
3166
|
-
[x: string]: any;
|
|
3167
|
-
}>, ...z.ZodObject<any, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
3168
|
-
[x: string]: any;
|
|
3169
|
-
}, {
|
|
3170
|
-
[x: string]: any;
|
|
3171
|
-
}>[]]>, "many">;
|
|
3172
|
-
shapes: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<any, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
3173
|
-
[x: string]: any;
|
|
3174
|
-
}, {
|
|
3175
|
-
[x: string]: any;
|
|
3176
|
-
}>, z.ZodObject<any, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
3177
|
-
[x: string]: any;
|
|
3178
|
-
}, {
|
|
3179
|
-
[x: string]: any;
|
|
3180
|
-
}>, ...z.ZodObject<any, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
3181
|
-
[x: string]: any;
|
|
3182
|
-
}, {
|
|
3183
|
-
[x: string]: any;
|
|
3184
|
-
}>[]]>, "many">>;
|
|
3185
|
-
}, "strip", z.ZodTypeAny, {
|
|
3186
|
-
points: {
|
|
3187
|
-
[x: string]: any;
|
|
3188
|
-
}[];
|
|
3189
|
-
version: 1;
|
|
3190
|
-
shapes: {
|
|
3191
|
-
[x: string]: any;
|
|
3192
|
-
}[];
|
|
3193
|
-
}, {
|
|
3194
|
-
points: {
|
|
3195
|
-
[x: string]: any;
|
|
3196
|
-
}[];
|
|
3197
|
-
version: 1;
|
|
3198
|
-
shapes?: {
|
|
3199
|
-
[x: string]: any;
|
|
3200
|
-
}[] | undefined;
|
|
3201
|
-
}>>;
|
|
3202
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
3203
|
-
}, "strip", z.ZodTypeAny, {
|
|
3204
|
-
decision: "refuse" | "add" | "replace";
|
|
3205
|
-
reason?: string | undefined;
|
|
3206
|
-
figure?: {
|
|
3207
|
-
points: {
|
|
3208
|
-
[x: string]: any;
|
|
3209
|
-
}[];
|
|
3210
|
-
version: 1;
|
|
3211
|
-
shapes: {
|
|
3212
|
-
[x: string]: any;
|
|
3213
|
-
}[];
|
|
3214
|
-
} | undefined;
|
|
3215
|
-
}, {
|
|
3216
|
-
decision: "refuse" | "add" | "replace";
|
|
3217
|
-
reason?: string | undefined;
|
|
3218
|
-
figure?: {
|
|
3219
|
-
points: {
|
|
3220
|
-
[x: string]: any;
|
|
3221
|
-
}[];
|
|
3222
|
-
version: 1;
|
|
3223
|
-
shapes?: {
|
|
3224
|
-
[x: string]: any;
|
|
3225
|
-
}[] | undefined;
|
|
3226
|
-
} | undefined;
|
|
3227
|
-
}>, {
|
|
3228
|
-
decision: "refuse" | "add" | "replace";
|
|
3229
|
-
reason?: string | undefined;
|
|
3230
|
-
figure?: {
|
|
3231
|
-
points: {
|
|
3232
|
-
[x: string]: any;
|
|
3233
|
-
}[];
|
|
3234
|
-
version: 1;
|
|
3235
|
-
shapes: {
|
|
3236
|
-
[x: string]: any;
|
|
3237
|
-
}[];
|
|
3238
|
-
} | undefined;
|
|
3239
|
-
}, {
|
|
3240
|
-
decision: "refuse" | "add" | "replace";
|
|
3241
|
-
reason?: string | undefined;
|
|
3242
|
-
figure?: {
|
|
3243
|
-
points: {
|
|
3244
|
-
[x: string]: any;
|
|
3245
|
-
}[];
|
|
3246
|
-
version: 1;
|
|
3247
|
-
shapes?: {
|
|
3248
|
-
[x: string]: any;
|
|
3249
|
-
}[] | undefined;
|
|
3250
|
-
} | undefined;
|
|
3251
|
-
}>;
|
|
3252
|
-
type FigureRefineEnvelopeT = z.infer<typeof FigureRefineEnvelopeZ>;
|
|
3253
|
-
declare function refineEnvelopeJsonSchema(): Record<string, unknown>;
|
|
3254
|
-
|
|
3255
3251
|
declare function intentEnvelopeJsonSchema(): Record<string, unknown>;
|
|
3256
3252
|
declare function envelopeIntentList(env: IntentEnvelopeT): readonly IntentT[];
|
|
3257
3253
|
|
|
@@ -3343,41 +3339,6 @@ declare function tryPartialDeterministic(problem: string): PartialDeterministicR
|
|
|
3343
3339
|
*/
|
|
3344
3340
|
declare function mergeIntents(det: readonly IntentT[], llm: readonly IntentT[]): IntentT[];
|
|
3345
3341
|
|
|
3346
|
-
declare function buildVisionSystemPrompt(): string;
|
|
3347
|
-
declare const VISION_USER_PROMPT = "\u0110\u1ECDc \u0111\u1EC1 b\u00E0i h\u00ECnh h\u1ECDc trong \u1EA3nh sau.";
|
|
3348
|
-
|
|
3349
|
-
declare const VisionEnvelopeZ: z.ZodEffects<z.ZodObject<{
|
|
3350
|
-
decision: z.ZodEnum<["extract", "refuse"]>;
|
|
3351
|
-
text: z.ZodOptional<z.ZodString>;
|
|
3352
|
-
confidence: z.ZodOptional<z.ZodEnum<["high", "low"]>>;
|
|
3353
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
3354
|
-
}, "strip", z.ZodTypeAny, {
|
|
3355
|
-
decision: "extract" | "refuse";
|
|
3356
|
-
text?: string | undefined;
|
|
3357
|
-
reason?: string | undefined;
|
|
3358
|
-
confidence?: "high" | "low" | undefined;
|
|
3359
|
-
}, {
|
|
3360
|
-
decision: "extract" | "refuse";
|
|
3361
|
-
text?: string | undefined;
|
|
3362
|
-
reason?: string | undefined;
|
|
3363
|
-
confidence?: "high" | "low" | undefined;
|
|
3364
|
-
}>, {
|
|
3365
|
-
decision: "extract" | "refuse";
|
|
3366
|
-
text?: string | undefined;
|
|
3367
|
-
reason?: string | undefined;
|
|
3368
|
-
confidence?: "high" | "low" | undefined;
|
|
3369
|
-
}, {
|
|
3370
|
-
decision: "extract" | "refuse";
|
|
3371
|
-
text?: string | undefined;
|
|
3372
|
-
reason?: string | undefined;
|
|
3373
|
-
confidence?: "high" | "low" | undefined;
|
|
3374
|
-
}>;
|
|
3375
|
-
type VisionEnvelopeT = z.infer<typeof VisionEnvelopeZ>;
|
|
3376
|
-
declare function visionEnvelopeJsonSchema(): Record<string, unknown>;
|
|
3377
|
-
|
|
3378
|
-
declare const MAX_EDGE_PX = 2048;
|
|
3379
|
-
declare const MAX_RAW_BYTES: number;
|
|
3380
|
-
declare const MAX_ENCODED_BYTES: number;
|
|
3381
3342
|
declare const ALLOWED_TYPES: readonly ["image/png", "image/jpeg", "image/webp"];
|
|
3382
3343
|
type AllowedType = (typeof ALLOWED_TYPES)[number];
|
|
3383
3344
|
type ValidationResult = {
|
|
@@ -3396,4 +3357,16 @@ declare function validateFile(file: File): ValidationResult;
|
|
|
3396
3357
|
*/
|
|
3397
3358
|
declare function fileToImagePart(file: File): Promise<ImagePart>;
|
|
3398
3359
|
|
|
3399
|
-
|
|
3360
|
+
interface TesseractOcrOptions {
|
|
3361
|
+
/** Tesseract language code. Default 'vie+eng' cho đề toán VN. */
|
|
3362
|
+
lang?: string;
|
|
3363
|
+
signal?: AbortSignal;
|
|
3364
|
+
}
|
|
3365
|
+
interface TesseractOcrResult {
|
|
3366
|
+
text: string;
|
|
3367
|
+
/** Confidence 0–100 (Tesseract scale). */
|
|
3368
|
+
confidence: number;
|
|
3369
|
+
}
|
|
3370
|
+
declare function runTesseractOcr(image: ImagePart, opts?: TesseractOcrOptions): Promise<TesseractOcrResult>;
|
|
3371
|
+
|
|
3372
|
+
export { type AddPointIntentT, type AiFigureIntentUiResult, type ConnectIntentT, type DeterministicFigure, type DrawCircleIntentT, type DrawShapeIntentT, type FigureEnvelopeT, FigureEnvelopeZ, type GenerateIntentOptions, type HandleGenerateFigureInput, type HandleGenerateFigureIntentInput, type HandleGenerateFigureIntentOptions, type HandleGenerateFigureOptions, ImagePart, IntentBuilderError, type IntentEnvelopeT, IntentEnvelopeZ, type IntentFailureResult, type IntentGenerateResult, type IntentSuccessResult, type IntentT, IntentZ, type PartialDeterministicResult, type TryDeterministicResult, type ValidationResult, type VerifyIssue, type VerifyReport, buildIntentSystemPrompt, compareIntents, envelopeBuildDsl, envelopeIntentList, envelopeJsonSchema, fileToImagePart, generateFigureIntent, handleGenerateFigure, handleGenerateFigureIntent, inferMediaType, intentEnvelopeJsonSchema, intentsToDsl, mergeIntents, runTesseractOcr, tryDeterministicFigure, tryPartialDeterministic, validateFile, verifyGeometry };
|