llmz 0.1.5 → 0.2.1
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/README.md +185 -98
- package/dist/chat.d.ts +34 -0
- package/dist/chunk-665O7CAN.js +788 -0
- package/dist/chunk-DD4AZSP5.cjs +788 -0
- package/dist/{chunk-EFEF2AL7.js → chunk-DH35WO5G.js} +93 -556
- package/dist/chunk-E5NHK3FS.js +1637 -0
- package/dist/{chunk-WODK7Y4J.cjs → chunk-ETYFOCWC.cjs} +2 -2
- package/dist/{chunk-IRCB4FRM.js → chunk-GC5IQDGV.js} +1 -1
- package/dist/{chunk-L74UZONX.js → chunk-HM5H556L.js} +3 -1
- package/dist/chunk-I56MPOVG.cjs +62 -0
- package/dist/chunk-KWQTYXAT.js +62 -0
- package/dist/{chunk-C7T6OJB4.cjs → chunk-MY26EAOP.cjs} +146 -88
- package/dist/{chunk-JXD2KJVB.cjs → chunk-WWZ2W4WR.cjs} +103 -566
- package/dist/chunk-YGKQEVQQ.cjs +1637 -0
- package/dist/{chunk-ZPHRTTQX.cjs → chunk-YQT5G77W.cjs} +3 -1
- package/dist/{chunk-TIZWOIDF.js → chunk-ZWUWCRHG.js} +135 -77
- package/dist/compiler/compiler.d.ts +7 -2
- package/dist/compiler/index.d.ts +1 -1
- package/dist/compiler/plugins/async-wrapper.d.ts +11 -0
- package/dist/component-2NYFY6CW.cjs +14 -0
- package/dist/{component-2Z3KLWLX.js → component-ASNZHQUR.js} +3 -7
- package/dist/component.d.ts +3 -10
- package/dist/context.d.ts +88 -2
- package/dist/{dual-modes-HEXPFVUE.js → dual-modes-RMF7V7ZQ.js} +2 -4
- package/dist/dual-modes-ZZY6QPYT.cjs +10 -0
- package/dist/{execute-22PSGL7P.cjs → execute-2AGZ5QUN.cjs} +333 -89
- package/dist/{execute-ZENBZBWL.js → execute-LNUBLVMZ.js} +323 -79
- package/dist/formatting.d.ts +1 -2
- package/dist/index.cjs +511 -36
- package/dist/index.d.ts +8 -5
- package/dist/index.js +495 -20
- package/dist/message-stream/index.d.ts +9 -0
- package/dist/message-stream/instructions.d.ts +22 -0
- package/dist/message-stream/normalizer.d.ts +21 -0
- package/dist/message-stream/parser.d.ts +81 -0
- package/dist/message-stream/registry.d.ts +14 -0
- package/dist/message-stream/replayable.d.ts +27 -0
- package/dist/message-stream/sanitize.d.ts +10 -0
- package/dist/message-stream/stream.d.ts +54 -0
- package/dist/message-stream/types.d.ts +96 -0
- package/dist/message-stream/validator.d.ts +23 -0
- package/dist/message-stream/validator.test.d.ts +1 -0
- package/dist/prompts/chat-mode/system.md.d.ts +1 -1
- package/dist/prompts/chat-mode/user.md.d.ts +1 -1
- package/dist/prompts/common.d.ts +5 -5
- package/dist/prompts/prompt.d.ts +43 -6
- package/dist/prompts/protocol.d.ts +18 -0
- package/dist/prompts/worker-mode/system.md.d.ts +1 -1
- package/dist/prompts/worker-mode/user.md.d.ts +1 -1
- package/dist/result.d.ts +31 -0
- package/dist/runtime/execute.test.d.ts +1 -0
- package/dist/runtime/generate.d.ts +24 -1
- package/dist/runtime/interpret-result.d.ts +10 -0
- package/dist/runtime/types.d.ts +29 -4
- package/dist/{tool-DNHVW3KC.js → tool-HTAYKIA2.js} +2 -2
- package/dist/{tool-GJ6ZXWS2.cjs → tool-V55GD2FS.cjs} +3 -3
- package/dist/truncator-7PGEGCHV.cjs +12 -0
- package/dist/{truncator-3U2QUUJJ.js → truncator-OZOBNYON.js} +3 -1
- package/dist/truncator.d.ts +2 -0
- package/dist/types.d.ts +8 -1
- package/dist/{typings-ZTFPPA5W.cjs → typings-S6I6IPTG.cjs} +2 -2
- package/dist/{typings-3YV3RDMP.js → typings-SCKZCAPN.js} +1 -1
- package/dist/typings-formatter.d.ts +15 -0
- package/dist/typings-formatter.test.d.ts +1 -0
- package/dist/vm/drivers/quickjs.d.ts +2 -0
- package/dist/vm/index.d.ts +7 -0
- package/dist/vm/instrument.d.ts +1 -1
- package/dist/{vm-PYCKS77H.js → vm-44H4UKI2.js} +5 -4
- package/dist/{vm-VHB67FVH.cjs → vm-A3OTQVIR.cjs} +4 -3
- package/package.json +6 -7
- package/dist/chunk-2O3UTPVH.js +0 -813
- package/dist/chunk-3T5IU7OU.js +0 -186
- package/dist/chunk-7LMIOS6H.cjs +0 -287
- package/dist/chunk-BBX2LDZE.cjs +0 -813
- package/dist/chunk-CQ3UJW76.cjs +0 -186
- package/dist/chunk-TOGYDN6U.js +0 -287
- package/dist/compiler/plugins/async-iterator.d.ts +0 -6
- package/dist/compiler/plugins/braces-tsx.d.ts +0 -3
- package/dist/compiler/plugins/html-to-markdown.d.ts +0 -21
- package/dist/compiler/plugins/jsx-preserve-newlines.d.ts +0 -5
- package/dist/compiler/plugins/jsx-undefined-vars.d.ts +0 -14
- package/dist/component-NNHBHD72.cjs +0 -18
- package/dist/dual-modes-LLIWZCHC.cjs +0 -12
- package/dist/truncator-3ZN7W6NB.cjs +0 -10
- /package/dist/{compiler/plugins/html-to-markdown.test.d.ts → message-stream/instructions.test.d.ts} +0 -0
- /package/dist/{compiler/plugins/jsx-undefined-vars.test.d.ts → message-stream/normalizer.test.d.ts} +0 -0
- /package/dist/{component.test.d.ts → message-stream/parser.test.d.ts} +0 -0
- /package/dist/{vm/vm-jsx.test.d.ts → message-stream/stream.test.d.ts} +0 -0
package/dist/result.d.ts
CHANGED
|
@@ -291,6 +291,28 @@ export declare abstract class ExecutionResult implements Serializable<ExecutionR
|
|
|
291
291
|
* ```
|
|
292
292
|
*/
|
|
293
293
|
get iterations(): Iteration[];
|
|
294
|
+
/**
|
|
295
|
+
* Gets the total token usage of the execution, aggregated across all iterations.
|
|
296
|
+
*
|
|
297
|
+
* `input`/`output` are the provider-reported token counts of every LLM call made
|
|
298
|
+
* during the execution. Per-iteration detail (including the measured context size
|
|
299
|
+
* breakdown by prompt part) is available on each iteration's `tokens` property.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```typescript
|
|
303
|
+
* const result = await execute({ ... })
|
|
304
|
+
* console.log(`Execution used ${result.tokens.total} tokens`)
|
|
305
|
+
*
|
|
306
|
+
* for (const iteration of result.iterations) {
|
|
307
|
+
* console.log(iteration.id, iteration.tokens?.context)
|
|
308
|
+
* }
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
get tokens(): {
|
|
312
|
+
input: number;
|
|
313
|
+
output: number;
|
|
314
|
+
total: number;
|
|
315
|
+
};
|
|
294
316
|
abstract toJSON(): ExecutionResult.JSON;
|
|
295
317
|
}
|
|
296
318
|
export declare namespace SuccessExecutionResult {
|
|
@@ -406,6 +428,8 @@ export declare class SuccessExecutionResult<TOutput = unknown> extends Execution
|
|
|
406
428
|
spend: number;
|
|
407
429
|
output: string;
|
|
408
430
|
model: string;
|
|
431
|
+
time_to_first_token?: number;
|
|
432
|
+
time_to_last_token?: number;
|
|
409
433
|
usage: {
|
|
410
434
|
inputCost: number;
|
|
411
435
|
outputCost: number;
|
|
@@ -413,6 +437,7 @@ export declare class SuccessExecutionResult<TOutput = unknown> extends Execution
|
|
|
413
437
|
outputTokens: number;
|
|
414
438
|
};
|
|
415
439
|
} | undefined;
|
|
440
|
+
tokens: import("./context.js").TokenUsage | undefined;
|
|
416
441
|
transcript: import("./transcript.js").Transcript.Message[];
|
|
417
442
|
tools: {
|
|
418
443
|
name: string;
|
|
@@ -568,6 +593,8 @@ export declare class ErrorExecutionResult extends ExecutionResult implements Ser
|
|
|
568
593
|
spend: number;
|
|
569
594
|
output: string;
|
|
570
595
|
model: string;
|
|
596
|
+
time_to_first_token?: number;
|
|
597
|
+
time_to_last_token?: number;
|
|
571
598
|
usage: {
|
|
572
599
|
inputCost: number;
|
|
573
600
|
outputCost: number;
|
|
@@ -575,6 +602,7 @@ export declare class ErrorExecutionResult extends ExecutionResult implements Ser
|
|
|
575
602
|
outputTokens: number;
|
|
576
603
|
};
|
|
577
604
|
} | undefined;
|
|
605
|
+
tokens: import("./context.js").TokenUsage | undefined;
|
|
578
606
|
transcript: import("./transcript.js").Transcript.Message[];
|
|
579
607
|
tools: {
|
|
580
608
|
name: string;
|
|
@@ -750,6 +778,8 @@ export declare class PartialExecutionResult extends ExecutionResult implements S
|
|
|
750
778
|
spend: number;
|
|
751
779
|
output: string;
|
|
752
780
|
model: string;
|
|
781
|
+
time_to_first_token?: number;
|
|
782
|
+
time_to_last_token?: number;
|
|
753
783
|
usage: {
|
|
754
784
|
inputCost: number;
|
|
755
785
|
outputCost: number;
|
|
@@ -757,6 +787,7 @@ export declare class PartialExecutionResult extends ExecutionResult implements S
|
|
|
757
787
|
outputTokens: number;
|
|
758
788
|
};
|
|
759
789
|
} | undefined;
|
|
790
|
+
tokens: import("./context.js").TokenUsage | undefined;
|
|
760
791
|
transcript: import("./transcript.js").Transcript.Message[];
|
|
761
792
|
tools: {
|
|
762
793
|
name: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { MessageDelta } from '../chat.js';
|
|
1
2
|
import { Context, Iteration } from '../context.js';
|
|
3
|
+
import type { ParsedSend } from '../prompts/prompt.js';
|
|
2
4
|
import { RuntimeCognitive } from './types.js';
|
|
3
5
|
type GenerateCodeProps = {
|
|
4
6
|
iteration: Iteration;
|
|
@@ -6,6 +8,27 @@ type GenerateCodeProps = {
|
|
|
6
8
|
cognitive: RuntimeCognitive;
|
|
7
9
|
controller: AbortController;
|
|
8
10
|
metadata?: Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* Called for each completed `■send` block. On streaming clients this fires
|
|
13
|
+
* while the model is still generating — messages are delivered progressively.
|
|
14
|
+
*/
|
|
15
|
+
onSend?: (send: ParsedSend) => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Called for each `■send` body chunk as it is parsed from the stream
|
|
18
|
+
* (streaming clients only). Best-effort: errors are ignored.
|
|
19
|
+
*/
|
|
20
|
+
onSendDelta?: (delta: MessageDelta) => Promise<void> | void;
|
|
21
|
+
/**
|
|
22
|
+
* Called as soon as the model opens a `■run` block, while the code is still
|
|
23
|
+
* being generated (streaming clients only). Used to pre-warm the VM.
|
|
24
|
+
*/
|
|
25
|
+
onRunStart?: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* Called with the code of the first `■run` block the moment it is fully
|
|
28
|
+
* parsed — the rest of the response (e.g. `■next`) may still be streaming
|
|
29
|
+
* (streaming clients only). Used to start executing the code early.
|
|
30
|
+
*/
|
|
31
|
+
onRunComplete?: (code: string) => void;
|
|
9
32
|
};
|
|
10
|
-
export declare const generateCode: ({ iteration, ctx, cognitive, controller, metadata }: GenerateCodeProps) => Promise<void>;
|
|
33
|
+
export declare const generateCode: ({ iteration, ctx, cognitive, controller, metadata, onSend, onSendDelta, onRunStart, onRunComplete, }: GenerateCodeProps) => Promise<void>;
|
|
11
34
|
export {};
|
|
@@ -9,4 +9,14 @@ type InterpretVMResultProps = {
|
|
|
9
9
|
onExit?: ExecutionHooks['onExit'];
|
|
10
10
|
};
|
|
11
11
|
export declare const interpretVMResult: ({ iteration, result, controller, startedAt, onExit, }: InterpretVMResultProps) => Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Applies the `■next=<exit>` block of the current iteration: validates the exit
|
|
14
|
+
* name and props against the available exits, runs the onExit hook, and ends
|
|
15
|
+
* the iteration with exit_success or exit_error.
|
|
16
|
+
*/
|
|
17
|
+
export declare const applyNextExit: ({ iteration, controller, onExit, }: {
|
|
18
|
+
iteration: Iteration;
|
|
19
|
+
controller: AbortController;
|
|
20
|
+
onExit?: ExecutionHooks["onExit"];
|
|
21
|
+
}) => Promise<void>;
|
|
12
22
|
export {};
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cognitive, CognitiveBeta, type BotpressClientLike, Models } from '@botpress/cognitive';
|
|
1
|
+
import { Cognitive, CognitiveBeta, type BotpressClientLike, type CognitiveLike, Models } from '@botpress/cognitive';
|
|
2
2
|
import { Chat } from '../chat.js';
|
|
3
3
|
import { Context, Iteration } from '../context.js';
|
|
4
4
|
import { _CustomModelClient } from '../custom-client.js';
|
|
@@ -17,10 +17,13 @@ export type ExecutionHooks = {
|
|
|
17
17
|
*
|
|
18
18
|
* This hook is called for each trace that is generated during the iteration.
|
|
19
19
|
* It is useful for logging, debugging, or monitoring the execution of the iteration.
|
|
20
|
+
* The abort controller can be used to stop the execution when a trace reveals
|
|
21
|
+
* something that should halt it (e.g. a forbidden tool call).
|
|
20
22
|
*/
|
|
21
23
|
onTrace?: (event: {
|
|
22
24
|
trace: Trace;
|
|
23
25
|
iteration: number;
|
|
26
|
+
controller: AbortController;
|
|
24
27
|
}) => void;
|
|
25
28
|
/**
|
|
26
29
|
* BLOCKING HOOK
|
|
@@ -50,8 +53,9 @@ export type ExecutionHooks = {
|
|
|
50
53
|
* It is useful for logging, sending notifications, or performing actions based on the exit.
|
|
51
54
|
* It can also be used to throw an error and preventing the exit from being successful.
|
|
52
55
|
* If this hook throws an error, the execution will keep iterating with the error as context.
|
|
56
|
+
* The abort controller can be used to stop the execution entirely instead of iterating.
|
|
53
57
|
*/
|
|
54
|
-
onExit?: <T = unknown>(result: ExitResult<T
|
|
58
|
+
onExit?: <T = unknown>(result: ExitResult<T>, controller: AbortController) => Promise<void> | void;
|
|
55
59
|
/**
|
|
56
60
|
* BLOCKING HOOK
|
|
57
61
|
* This hook will block the execution of the iteration until it resolves.
|
|
@@ -104,7 +108,21 @@ export type ExecutionHooks = {
|
|
|
104
108
|
output?: any;
|
|
105
109
|
} | void>;
|
|
106
110
|
};
|
|
107
|
-
type Options = Partial<Pick<Context, 'loop' | 'timeout'
|
|
111
|
+
type Options = Partial<Pick<Context, 'loop' | 'timeout'>> & {
|
|
112
|
+
/**
|
|
113
|
+
* Optional cap on the model's context window, in tokens.
|
|
114
|
+
* The effective limit is `min(maxTokens, model's max input tokens)`.
|
|
115
|
+
* Useful to reduce cost and latency on models with very large context windows.
|
|
116
|
+
*/
|
|
117
|
+
maxTokens?: number;
|
|
118
|
+
/**
|
|
119
|
+
* Maximum time to wait for the first streamed token, in milliseconds, before
|
|
120
|
+
* the cognitive service falls back to the next model/provider. Only applies
|
|
121
|
+
* to streaming clients (CognitiveBeta / Cognitive v2), and works best when
|
|
122
|
+
* `model` is an array of fallback models.
|
|
123
|
+
*/
|
|
124
|
+
maxTimeToFirstToken?: number;
|
|
125
|
+
};
|
|
108
126
|
export type ExecutionProps = {
|
|
109
127
|
/**
|
|
110
128
|
* If provided, the execution will be run in "Chat Mode".
|
|
@@ -211,5 +229,12 @@ export type ExecutionProps = {
|
|
|
211
229
|
*/
|
|
212
230
|
metadata?: Record<string, string>;
|
|
213
231
|
} & ExecutionHooks;
|
|
214
|
-
export type RuntimeCognitive = Pick<Cognitive, 'getModelDetails' | 'generateContent'
|
|
232
|
+
export type RuntimeCognitive = Pick<Cognitive, 'getModelDetails' | 'generateContent'> & {
|
|
233
|
+
/**
|
|
234
|
+
* Streaming generation. Only available on clients backed by the Cognitive v2
|
|
235
|
+
* (beta) API — when present, the runtime streams the response and parses
|
|
236
|
+
* ■ blocks incrementally.
|
|
237
|
+
*/
|
|
238
|
+
generateContentStream?: CognitiveLike['generateContentStream'];
|
|
239
|
+
};
|
|
215
240
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var _chunkETYFOCWCcjs = require('./chunk-ETYFOCWC.cjs');
|
|
4
|
+
require('./chunk-DD4AZSP5.cjs');
|
|
5
5
|
require('./chunk-PK72FAKD.cjs');
|
|
6
6
|
require('./chunk-KIN7Y247.cjs');
|
|
7
7
|
require('./chunk-FPLSJF4S.cjs');
|
|
8
8
|
require('./chunk-HC2QZTVT.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
exports.Tool =
|
|
11
|
+
exports.Tool = _chunkETYFOCWCcjs.Tool;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkYQT5G77Wcjs = require('./chunk-YQT5G77W.cjs');
|
|
6
|
+
require('./chunk-FPLSJF4S.cjs');
|
|
7
|
+
require('./chunk-HC2QZTVT.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.stripTruncationTags = _chunkYQT5G77Wcjs.stripTruncationTags; exports.truncateWrappedContent = _chunkYQT5G77Wcjs.truncateWrappedContent; exports.wrapContent = _chunkYQT5G77Wcjs.wrapContent;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
stripTruncationTags,
|
|
2
3
|
truncateWrappedContent,
|
|
3
4
|
wrapContent
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HM5H556L.js";
|
|
5
6
|
import "./chunk-YX27XM67.js";
|
|
6
7
|
import "./chunk-34GJUS6U.js";
|
|
7
8
|
export {
|
|
9
|
+
stripTruncationTags,
|
|
8
10
|
truncateWrappedContent,
|
|
9
11
|
wrapContent
|
|
10
12
|
};
|
package/dist/truncator.d.ts
CHANGED
|
@@ -113,4 +113,6 @@ export declare function wrapContent(content: string, options?: Partial<TruncateO
|
|
|
113
113
|
* ```
|
|
114
114
|
*/
|
|
115
115
|
export declare function truncateWrappedContent<T extends MessageLike>({ messages, tokenLimit, throwOnFailure, }: Options<T>): T[];
|
|
116
|
+
/** Removes truncation wrapper tags from content, leaving the wrapped content intact. */
|
|
117
|
+
export declare const stripTruncationTags: (content: string) => string;
|
|
116
118
|
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -55,6 +55,13 @@ export declare namespace Traces {
|
|
|
55
55
|
model: string;
|
|
56
56
|
code: string;
|
|
57
57
|
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Emitted on streaming clients the moment the model starts writing a `■run`
|
|
60
|
+
* block — before the code is fully generated. Useful to show a
|
|
61
|
+
* "writing code..." indicator while waiting for `llm_call_success` (which
|
|
62
|
+
* carries the final code) and the subsequent execution.
|
|
63
|
+
*/
|
|
64
|
+
type CodeGenerationStart = TraceTemplate<'code_generation_started', {}>;
|
|
58
65
|
type AbortTrace = TraceTemplate<'abort_signal', {
|
|
59
66
|
reason: string;
|
|
60
67
|
}>;
|
|
@@ -70,7 +77,7 @@ export declare namespace Traces {
|
|
|
70
77
|
started_at: number;
|
|
71
78
|
ended_at?: number;
|
|
72
79
|
} & Content;
|
|
73
|
-
type Trace = Comment | Log | ToolCall | ToolSlow | PropertyMutation | YieldTrace | LLMCallStart | LLMCallSuccess | ThinkSignal | CodeExecution | CodeExecutionException | InvalidCodeExceptionTrace | AbortTrace;
|
|
80
|
+
type Trace = Comment | Log | ToolCall | ToolSlow | PropertyMutation | YieldTrace | LLMCallStart | LLMCallSuccess | CodeGenerationStart | ThinkSignal | CodeExecution | CodeExecutionException | InvalidCodeExceptionTrace | AbortTrace;
|
|
74
81
|
}
|
|
75
82
|
export type Trace = Traces.Trace;
|
|
76
83
|
export type VMExecutionResult = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkDD4AZSP5cjs = require('./chunk-DD4AZSP5.cjs');
|
|
4
4
|
require('./chunk-PK72FAKD.cjs');
|
|
5
5
|
require('./chunk-KIN7Y247.cjs');
|
|
6
6
|
require('./chunk-FPLSJF4S.cjs');
|
|
7
7
|
require('./chunk-HC2QZTVT.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
exports.getTypings =
|
|
10
|
+
exports.getTypings = _chunkDD4AZSP5cjs.getTypings;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal, dependency-free formatter for the TypeScript typings generated by
|
|
3
|
+
* llmz (typings.ts, objects.ts, hoist.ts). It supports only the small grammar
|
|
4
|
+
* those generators emit — type expressions, `declare const` / `declare function`
|
|
5
|
+
* declarations, `type` aliases and `export namespace` blocks — and produces
|
|
6
|
+
* prettier-like output: 80 columns, 2-space indent, no semicolons in broken
|
|
7
|
+
* objects, hugged single-object function params, unions wrapped with leading `|`.
|
|
8
|
+
*
|
|
9
|
+
* If the input cannot be tokenized or has unbalanced brackets, it is returned
|
|
10
|
+
* unchanged.
|
|
11
|
+
*/
|
|
12
|
+
/** Formats typings, throwing on input it cannot parse (unbalanced brackets, etc.) */
|
|
13
|
+
export declare function formatTypingsUnsafe(typings: string): string;
|
|
14
|
+
/** Formats typings, returning the input unchanged when it cannot be parsed */
|
|
15
|
+
export declare function formatTypings(typings: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { type QuickJSWASMModule } from 'quickjs-emscripten-core';
|
|
1
2
|
import type { VMExecutionResult } from '../../types.js';
|
|
2
3
|
import type { DriverExecutionContext, VMDriver } from '../types.js';
|
|
4
|
+
export declare const loadQuickJSModule: () => Promise<QuickJSWASMModule>;
|
|
3
5
|
export declare class QuickJSDriver implements VMDriver {
|
|
4
6
|
execute(ctx: DriverExecutionContext): Promise<VMExecutionResult>;
|
|
5
7
|
private _pumpEventLoop;
|
package/dist/vm/index.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import type { Trace, VMExecutionResult } from '../types.js';
|
|
2
2
|
import type { VMContext } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Pre-warms the VM so the first execution doesn't pay the QuickJS WASM
|
|
5
|
+
* instantiation cost. Fire-and-forget: called as soon as the model starts
|
|
6
|
+
* writing a `■run` block, so the module loads while the code is still being
|
|
7
|
+
* generated. No-op when the QuickJS driver is disabled or already loaded.
|
|
8
|
+
*/
|
|
9
|
+
export declare const warmupVM: () => void;
|
|
3
10
|
export declare function runAsyncFunction(context: VMContext, code: string, traces?: Trace[], signal?: AbortSignal | null, timeout?: number): Promise<VMExecutionResult>;
|
package/dist/vm/instrument.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type CompiledCode } from '../compiler/index.js';
|
|
|
3
3
|
import { SnapshotSignal } from '../errors.js';
|
|
4
4
|
import type { Trace } from '../types.js';
|
|
5
5
|
import { VMContext } from './types.js';
|
|
6
|
-
export declare const NO_TRACKING: readonly [string, string, string, string, string
|
|
6
|
+
export declare const NO_TRACKING: readonly [string, string, string, string, string];
|
|
7
7
|
export type InstrumentationState = {
|
|
8
8
|
currentToolCall: SnapshotSignal['toolCall'] | undefined;
|
|
9
9
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
runAsyncFunction
|
|
3
|
-
|
|
2
|
+
runAsyncFunction,
|
|
3
|
+
warmupVM
|
|
4
|
+
} from "./chunk-DH35WO5G.js";
|
|
4
5
|
import "./chunk-WSVDMGMR.js";
|
|
5
6
|
import "./chunk-YEAWWJSJ.js";
|
|
6
|
-
import "./chunk-XTEHT2TK.js";
|
|
7
7
|
import "./chunk-34GJUS6U.js";
|
|
8
8
|
export {
|
|
9
|
-
runAsyncFunction
|
|
9
|
+
runAsyncFunction,
|
|
10
|
+
warmupVM
|
|
10
11
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
var _chunkWWZ2W4WRcjs = require('./chunk-WWZ2W4WR.cjs');
|
|
4
5
|
require('./chunk-PK72FAKD.cjs');
|
|
5
6
|
require('./chunk-KIN7Y247.cjs');
|
|
6
|
-
require('./chunk-5ZF6NTYI.cjs');
|
|
7
7
|
require('./chunk-HC2QZTVT.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
exports.runAsyncFunction = _chunkWWZ2W4WRcjs.runAsyncFunction; exports.warmupVM = _chunkWWZ2W4WRcjs.warmupVM;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "llmz",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "LLMz - An LLM-native Typescript VM built on top of Zui",
|
|
5
|
-
"version": "0.1
|
|
5
|
+
"version": "0.2.1",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
8
8
|
"module": "./dist/index.js",
|
|
@@ -30,11 +30,8 @@
|
|
|
30
30
|
"author": "",
|
|
31
31
|
"license": "ISC",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@babel/core": "^7.26.0",
|
|
34
33
|
"@babel/generator": "^7.26.3",
|
|
35
34
|
"@babel/parser": "^7.26.3",
|
|
36
|
-
"@babel/plugin-transform-react-jsx": "^7.25.9",
|
|
37
|
-
"@babel/preset-typescript": "^7.26.0",
|
|
38
35
|
"@babel/standalone": "^7.26.4",
|
|
39
36
|
"@babel/traverse": "^7.26.4",
|
|
40
37
|
"@babel/types": "^7.26.3",
|
|
@@ -42,14 +39,15 @@
|
|
|
42
39
|
"bytes": "^3.1.2",
|
|
43
40
|
"exponential-backoff": "^3.1.1",
|
|
44
41
|
"handlebars": "^4.7.8",
|
|
42
|
+
"json5": "^2.2.3",
|
|
43
|
+
"jsonrepair": "^3.10.0",
|
|
45
44
|
"lodash-es": "^4.17.21",
|
|
46
|
-
"lru-cache": "~11.0.2",
|
|
47
45
|
"ms": "^2.1.3",
|
|
48
|
-
"prettier": "^3.4.2",
|
|
49
46
|
"quickjs-emscripten-core": "^0.31.0",
|
|
50
47
|
"ulid": "^2.3.0"
|
|
51
48
|
},
|
|
52
49
|
"devDependencies": {
|
|
50
|
+
"@babel/core": "^7.26.0",
|
|
53
51
|
"@botpress/cli": "workspace:*",
|
|
54
52
|
"@microsoft/api-extractor": "^7.49.0",
|
|
55
53
|
"@types/babel__core": "^7.20.5",
|
|
@@ -66,6 +64,7 @@
|
|
|
66
64
|
"dotenv": "^16.4.4",
|
|
67
65
|
"esbuild": "^0.25.10",
|
|
68
66
|
"glob": "^9.3.4",
|
|
67
|
+
"prettier": "^3.4.2",
|
|
69
68
|
"source-map-js": "1.2.1",
|
|
70
69
|
"tsup": "^8.0.2",
|
|
71
70
|
"tsx": "^4.19.2"
|
|
@@ -73,7 +72,7 @@
|
|
|
73
72
|
"peerDependencies": {
|
|
74
73
|
"@botpress/client": "1.49.0",
|
|
75
74
|
"@botpress/cognitive": "0.6.2",
|
|
76
|
-
"@bpinternal/thicktoken": "^
|
|
75
|
+
"@bpinternal/thicktoken": "^3.0.0",
|
|
77
76
|
"@bpinternal/zui": "^2.3.1"
|
|
78
77
|
},
|
|
79
78
|
"dependenciesMeta": {
|