llmz 0.9.0 → 1.0.2
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/DOCS.md +232 -1794
- package/ERRORS.md +101 -0
- package/README.md +96 -582
- package/dist/chat/chat.d.ts +63 -0
- package/dist/chat/component.d.ts +31 -0
- package/dist/chat/component.default.d.ts +58 -0
- package/dist/chat/response.d.ts +15 -0
- package/dist/compiler/compiler.d.ts +2 -7
- package/dist/compiler/plugins/dynamic-code.d.ts +7 -0
- package/dist/compiler/plugins/replace-comment.d.ts +2 -3
- package/dist/compiler/plugins/return-async.d.ts +5 -4
- package/dist/compiler/plugins/termination.d.ts +8 -0
- package/dist/compiler/plugins/tool-resolution.d.ts +4 -0
- package/dist/compiler/plugins/variable-extraction.d.ts +2 -8
- package/dist/component-CMFoCHyu.cjs +649 -0
- package/dist/component-DncqP4fB.js +614 -0
- package/dist/context.d.ts +71 -378
- package/dist/custom-client-C-WXvLD9.js +1655 -0
- package/dist/custom-client-Cgt9_0r1.cjs +1732 -0
- package/dist/custom-client.d.ts +12 -2
- package/dist/errors/catalog.d.ts +294 -0
- package/dist/errors/hooks.d.ts +2 -0
- package/dist/errors-C6ppQUZX.cjs +893 -0
- package/dist/errors-Crk5P8jo.js +636 -0
- package/dist/errors.d.ts +24 -36
- package/dist/execute-CiYvPs5Q.js +2061 -0
- package/dist/execute-DTTfacsi.cjs +2062 -0
- package/dist/{exit-DUM96DN1.cjs → exit-BOtKWPuT.cjs} +38 -28
- package/dist/{exit-CDdxDBRT.js → exit-DMPwCSba.js} +37 -27
- package/dist/exit.d.ts +19 -16
- package/dist/index.cjs +177 -1237
- package/dist/index.d.ts +25 -28
- package/dist/index.js +137 -1213
- package/dist/index.workerd.js +8974 -11145
- package/dist/inspect.d.ts +18 -4
- package/dist/inspection.d.ts +40 -0
- package/dist/native-0bq5ATZM.cjs +212 -0
- package/dist/native-n_718Z-T.js +177 -0
- package/dist/objects.d.ts +2 -57
- package/dist/prompts/native.d.ts +2 -0
- package/dist/prompts/prompt.d.ts +10 -101
- package/dist/quickjs-variant-21IO97PF.cjs +1080 -0
- package/dist/quickjs-variant-CtuGagsb.js +985 -0
- package/dist/result.d.ts +30 -861
- package/dist/runtime/execute.d.ts +3 -2
- package/dist/runtime/execution-activity.d.ts +11 -0
- package/dist/runtime/execution-diagnostics.d.ts +11 -0
- package/dist/runtime/execution-report.d.ts +51 -0
- package/dist/runtime/fixtures/chat.d.ts +8 -0
- package/dist/runtime/fixtures/long-search.d.ts +1 -1
- package/dist/runtime/fixtures/native-client.d.ts +33 -0
- package/dist/runtime/fixtures/protocol-languages.d.ts +1 -1
- package/dist/runtime/forced-inspection.d.ts +13 -0
- package/dist/runtime/forced-inspection.test.d.ts +1 -0
- package/dist/runtime/generate.d.ts +23 -20
- package/dist/runtime/generate.test.d.ts +1 -0
- package/dist/runtime/hook-provenance.test.d.ts +1 -0
- package/dist/runtime/inspection-hook.test.d.ts +1 -0
- package/dist/runtime/inspection-values.d.ts +14 -0
- package/dist/runtime/inspection-values.test.d.ts +1 -0
- package/dist/runtime/interruption-control-flow.test.d.ts +1 -0
- package/dist/runtime/interruption-settings.test.d.ts +1 -0
- package/dist/runtime/javascript-api.d.ts +62 -0
- package/dist/runtime/javascript-api.test.d.ts +1 -0
- package/dist/runtime/native-review.test.d.ts +1 -0
- package/dist/runtime/native-tools.d.ts +18 -0
- package/dist/runtime/native-tools.test.d.ts +1 -0
- package/dist/runtime/object-memory.test.d.ts +1 -0
- package/dist/runtime/single-tool.test.d.ts +1 -0
- package/dist/runtime/think-signal.test.d.ts +1 -0
- package/dist/runtime/token-budget.d.ts +22 -0
- package/dist/runtime/token-budget.test.d.ts +1 -0
- package/dist/runtime/tool-wrapper.d.ts +6 -5
- package/dist/runtime/traces.test.d.ts +1 -0
- package/dist/runtime/truncation.test.d.ts +1 -0
- package/dist/runtime/types.d.ts +47 -31
- package/dist/runtime/variable-recovery.test.d.ts +1 -0
- package/dist/runtime/vm-context.d.ts +6 -1
- package/dist/runtime/worker-completion.test.d.ts +1 -0
- package/dist/runtime-names.d.ts +4 -0
- package/dist/schema-CXlnbb3n.cjs +68 -0
- package/dist/schema-GE4ISPCR.js +45 -0
- package/dist/schema.d.ts +10 -0
- package/dist/schema.test.d.ts +1 -0
- package/dist/session/compactor.d.ts +51 -0
- package/dist/session/compactor.test.d.ts +1 -0
- package/dist/session/history.d.ts +36 -0
- package/dist/session/history.test.d.ts +1 -0
- package/dist/session/json.d.ts +3 -0
- package/dist/session/json.test.d.ts +1 -0
- package/dist/session/memory-codec.d.ts +9 -0
- package/dist/session/memory-codec.test.d.ts +1 -0
- package/dist/session/memory-render.d.ts +15 -0
- package/dist/session/memory-render.test.d.ts +1 -0
- package/dist/session/memory.d.ts +112 -0
- package/dist/session/memory.test.d.ts +1 -0
- package/dist/session/messages.d.ts +19 -0
- package/dist/session/messages.test.d.ts +1 -0
- package/dist/session/serialization.d.ts +36 -0
- package/dist/session/serialization.test.d.ts +1 -0
- package/dist/session/session-memory.test.d.ts +1 -0
- package/dist/session/session.d.ts +121 -0
- package/dist/session/session.test.d.ts +1 -0
- package/dist/session/speaker.test.d.ts +1 -0
- package/dist/{transcript.d.ts → session/transcript.d.ts} +4 -8
- package/dist/session/transcript.test.d.ts +1 -0
- package/dist/{tool-Bv8N4IPj.js → tool-DstssiAs.js} +144 -92
- package/dist/{tool-Dy6AJpJH.cjs → tool-_wK9hQOb.cjs} +146 -94
- package/dist/tool.d.ts +25 -17
- package/dist/truncate-BEKbdo3t.js +79 -0
- package/dist/truncate-uomAMGPs.cjs +102 -0
- package/dist/truncate.d.ts +24 -0
- package/dist/truncate.test.d.ts +1 -0
- package/dist/types.d.ts +33 -9
- package/dist/{typings-3lsqCbkn.cjs → typings-BA_XxAcY.cjs} +38 -193
- package/dist/{typings-CrBa7Tyy.js → typings-BEVDvtuk.js} +38 -175
- package/dist/typings-formatter.d.ts +1 -1
- package/dist/typings.d.ts +3 -0
- package/dist/{uniq-BYQ7GWwb.js → uniq-DfUeSNaX.js} +2 -2
- package/dist/{uniq-G872RWmE.cjs → uniq-DiXgysNV.cjs} +6 -18
- package/dist/{_baseIteratee-P_firB7b.js → utils-BOFzb8Ok.js} +1134 -16
- package/dist/{_baseIteratee-CF4qP2a8.cjs → utils-CTlsXvdj.cjs} +1281 -84
- package/dist/vm/drivers/node.d.ts +1 -1
- package/dist/vm/drivers/quickjs.d.ts +1 -1
- package/dist/vm/errors.d.ts +4 -4
- package/dist/vm/index.d.ts +3 -4
- package/dist/vm/instrument.d.ts +14 -6
- package/dist/vm/member-proxy.d.ts +4 -0
- package/dist/vm/member-proxy.test.d.ts +1 -0
- package/dist/vm/memory.test.d.ts +1 -0
- package/dist/vm/return-semantics.test.d.ts +1 -0
- package/dist/vm/types.d.ts +20 -3
- package/dist/{vm-BLsHw1da.js → vm-C7SfutHn.js} +1187 -180
- package/dist/{vm-D6s1zF6M.cjs → vm-gmekHc0i.cjs} +1221 -207
- package/package.json +13 -6
- package/dist/_baseForOwn-BfWDTL8L.cjs +0 -53
- package/dist/_baseForOwn-CFhWe_W6.js +0 -48
- package/dist/_getPrototype-CG7Dxrrz.js +0 -6
- package/dist/_getPrototype-DQDlNVVM.cjs +0 -10
- package/dist/_overArg-C5Hy7oCi.cjs +0 -196
- package/dist/_overArg-CRYbj1NH.js +0 -155
- package/dist/chat.d.ts +0 -401
- package/dist/common-BlRFtdf2.js +0 -807
- package/dist/common-BnvrDnIT.cjs +0 -860
- package/dist/compiler/plugins/track-tool-calls.d.ts +0 -33
- package/dist/compiler-C-OI9sim.cjs +0 -547
- package/dist/compiler-CW1VjQsn.js +0 -473
- package/dist/component-C6Agl2ns.cjs +0 -73
- package/dist/component-DGG7d_Mz.js +0 -44
- package/dist/component.d.ts +0 -88
- package/dist/component.default.d.ts +0 -278
- package/dist/custom-client-ChuZ63zp.js +0 -2658
- package/dist/custom-client-DAsGRnYc.cjs +0 -2729
- package/dist/dual-modes-DDkoCp3R.js +0 -3006
- package/dist/dual-modes-DPXiuvNe.cjs +0 -3090
- package/dist/errors-C962uJdS.cjs +0 -220
- package/dist/errors-Cg1G0Awu.js +0 -161
- package/dist/example-format.d.ts +0 -8
- package/dist/example.d.ts +0 -45
- package/dist/execute-BWcdv9so.js +0 -1059
- package/dist/execute-DM2-7y86.cjs +0 -1060
- package/dist/exit-parser.d.ts +0 -39
- package/dist/handlers.d.ts +0 -10
- package/dist/hoist.d.ts +0 -2
- package/dist/isEmpty-BhJRCqIF.js +0 -52
- package/dist/isEmpty-LY533Wmh.cjs +0 -57
- package/dist/isPlainObject-CSxXVKCk.cjs +0 -56
- package/dist/isPlainObject-D39AzPO2.js +0 -51
- package/dist/jsx-CIgdGGVs.js +0 -52
- package/dist/jsx-owqxrquU.cjs +0 -75
- package/dist/jsx.d.ts +0 -11
- package/dist/message-stream/index.d.ts +0 -9
- package/dist/message-stream/instructions.d.ts +0 -30
- package/dist/message-stream/normalizer.d.ts +0 -21
- package/dist/message-stream/parser.d.ts +0 -89
- package/dist/message-stream/registry.d.ts +0 -14
- package/dist/message-stream/replayable.d.ts +0 -27
- package/dist/message-stream/response-parser.d.ts +0 -24
- package/dist/message-stream/sanitize.d.ts +0 -10
- package/dist/message-stream/stream.d.ts +0 -54
- package/dist/message-stream/types.d.ts +0 -97
- package/dist/message-stream/validator.d.ts +0 -23
- package/dist/prompts/chat-mode/protocol.d.ts +0 -2
- package/dist/prompts/chat-mode/system.d.ts +0 -2
- package/dist/prompts/chat-mode/system.md.d.ts +0 -2
- package/dist/prompts/chat-mode/user.d.ts +0 -2
- package/dist/prompts/chat-mode/user.md.d.ts +0 -2
- package/dist/prompts/code-examples.d.ts +0 -2
- package/dist/prompts/common.d.ts +0 -7
- package/dist/prompts/dual-modes.d.ts +0 -2
- package/dist/prompts/execution-history.d.ts +0 -6
- package/dist/prompts/execution-state.d.ts +0 -3
- package/dist/prompts/protocol-basics.d.ts +0 -5
- package/dist/prompts/protocol.d.ts +0 -31
- package/dist/prompts/worker-mode/protocol.d.ts +0 -2
- package/dist/prompts/worker-mode/system.d.ts +0 -2
- package/dist/prompts/worker-mode/system.md.d.ts +0 -2
- package/dist/prompts/worker-mode/user.d.ts +0 -2
- package/dist/prompts/worker-mode/user.md.d.ts +0 -2
- package/dist/quickjs-variant-BYhMBpwU.js +0 -45
- package/dist/quickjs-variant-CsIwTVFC.cjs +0 -56
- package/dist/rolldown-runtime-EAsCxrDo.js +0 -14
- package/dist/runtime/fixtures/qwen-protocol-failures.d.ts +0 -29
- package/dist/runtime/interpret-result.d.ts +0 -22
- package/dist/snapshots.d.ts +0 -249
- package/dist/stack-traces-BIE_5Xwf.js +0 -21
- package/dist/stack-traces-ntw_qhoy.cjs +0 -26
- package/dist/truncator-CLkouTCO.cjs +0 -276
- package/dist/truncator-DZqEqnpD.js +0 -253
- package/dist/truncator.d.ts +0 -118
- package/dist/utils-3ESwP3yg.cjs +0 -1075
- package/dist/utils-UBeAFeEI.js +0 -950
- /package/dist/{citations.d.ts → chat/citations.d.ts} +0 -0
- /package/dist/{citations.test.d.ts → chat/citations.test.d.ts} +0 -0
- /package/dist/{component.default.test.d.ts → chat/component.default.test.d.ts} +0 -0
- /package/dist/{compiler/plugins/track-tool-calls.test.d.ts → chat/component.test.d.ts} +0 -0
- /package/dist/{example.test.d.ts → chat/response.test.d.ts} +0 -0
- /package/dist/{exit-parser.test.d.ts → compiler/plugins/dynamic-code.test.d.ts} +0 -0
- /package/dist/{handlers.test.d.ts → compiler/plugins/tool-resolution.test.d.ts} +0 -0
- /package/dist/{hoist.test.d.ts → errors/catalog.test.d.ts} +0 -0
- /package/dist/{message-stream/instructions.test.d.ts → exit.test.d.ts} +0 -0
- /package/dist/{message-stream/normalizer.test.d.ts → inspection.test.d.ts} +0 -0
- /package/dist/{message-stream/parser.test.d.ts → prompts/native.test.d.ts} +0 -0
- /package/dist/{message-stream/response-parser.test.d.ts → result.test.d.ts} +0 -0
- /package/dist/{message-stream/stream.test.d.ts → runtime/chat-completion.test.d.ts} +0 -0
- /package/dist/{message-stream/validator.test.d.ts → runtime/chat-delivery.test.d.ts} +0 -0
- /package/dist/{prompts/adherence.test.d.ts → runtime/chat-last-speaker.test.d.ts} +0 -0
- /package/dist/{prompts/catalogue-examples.test.d.ts → runtime/compatibility-regressions.test.d.ts} +0 -0
- /package/dist/{prompts/code-examples.test.d.ts → runtime/context-registration.test.d.ts} +0 -0
- /package/dist/{prompts/common.test.d.ts → runtime/empty-completion.test.d.ts} +0 -0
- /package/dist/{prompts/concrete-patterns.test.d.ts → runtime/error-recovery.test.d.ts} +0 -0
- /package/dist/{prompts/long-search.test.d.ts → runtime/errors.test.d.ts} +0 -0
- /package/dist/{prompts/protocol-simple.test.d.ts → runtime/execution-activity.test.d.ts} +0 -0
- /package/dist/{prompts/protocol.test.d.ts → runtime/execution-diagnostics.test.d.ts} +0 -0
- /package/dist/{prompts/sections.test.d.ts → runtime/execution-report.test.d.ts} +0 -0
- /package/dist/runtime/{interpret-result.test.d.ts → execution-safety.test.d.ts} +0 -0
- /package/dist/{transcript.test.d.ts → runtime/exit-control-flow.test.d.ts} +0 -0
- /package/dist/{truncator.test.d.ts → runtime/fixtures/long-search.test.d.ts} +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Context } from '../context.js';
|
|
2
|
+
import type { ValueOrGetter } from '../getter.js';
|
|
3
|
+
import type { ExecutionResult } from '../result.js';
|
|
4
|
+
import type { Component, RenderedComponent } from './component.js';
|
|
5
|
+
import type { Response } from './response.js';
|
|
6
|
+
/** Ordinary assistant output, independent of the configured response style. */
|
|
7
|
+
export type AssistantTextMessage = {
|
|
8
|
+
type: 'text';
|
|
9
|
+
text: string;
|
|
10
|
+
};
|
|
11
|
+
/** Text uses native assistant output; registered components provide rich UI. */
|
|
12
|
+
export type ChatMessage = AssistantTextMessage | RenderedComponent;
|
|
13
|
+
export type MessageMetadata = {
|
|
14
|
+
/** The iteration that owns this response or component send. */
|
|
15
|
+
iterationId: string;
|
|
16
|
+
/** Logical send ID, shared with its streamed text deltas. */
|
|
17
|
+
id: string;
|
|
18
|
+
};
|
|
19
|
+
/** Receives the complete committed assistant response. */
|
|
20
|
+
export type ResponseHandler = (text: string, metadata: MessageMetadata) => Promise<void> | void;
|
|
21
|
+
export type MessageDelta = {
|
|
22
|
+
restart: false;
|
|
23
|
+
type: 'text';
|
|
24
|
+
iterationId: string;
|
|
25
|
+
id: string;
|
|
26
|
+
/** New text since the preceding delta. */
|
|
27
|
+
delta: string;
|
|
28
|
+
/** Complete provisional text received so far. */
|
|
29
|
+
content: string;
|
|
30
|
+
} | {
|
|
31
|
+
/** Retract provisional text for this iteration before any replacement. */
|
|
32
|
+
restart: true;
|
|
33
|
+
iterationId: string;
|
|
34
|
+
attempt: number;
|
|
35
|
+
fromModel: string;
|
|
36
|
+
toModel: string;
|
|
37
|
+
reason: string;
|
|
38
|
+
};
|
|
39
|
+
/** Preview failures are ignored; failed retractions stop generation. */
|
|
40
|
+
export type MessageDeltaHandler = (delta: MessageDelta) => Promise<void> | void;
|
|
41
|
+
/**
|
|
42
|
+
* Connects native assistant replies and rich components to the host application.
|
|
43
|
+
*
|
|
44
|
+
* `response` controls how all assistant text is written. It does not create a
|
|
45
|
+
* JavaScript method or synthesize audio. `components` registers only rich UI
|
|
46
|
+
* methods such as chat.buttons or chat.image.
|
|
47
|
+
*
|
|
48
|
+
* Streamed deltas are provisional. After successful generation, the response
|
|
49
|
+
* handler receives the complete text with the same message ID. Each component
|
|
50
|
+
* owns its delivery handler. Without response callbacks, text remains available
|
|
51
|
+
* in the native session history.
|
|
52
|
+
*/
|
|
53
|
+
export declare class Chat {
|
|
54
|
+
readonly components: ValueOrGetter<Component[], Context>;
|
|
55
|
+
readonly response: ValueOrGetter<Response, Context>;
|
|
56
|
+
constructor(props?: {
|
|
57
|
+
components?: ValueOrGetter<Component[], Context>;
|
|
58
|
+
/** Resolved once per iteration; defaults to Markdown. */
|
|
59
|
+
response?: ValueOrGetter<Response, Context>;
|
|
60
|
+
});
|
|
61
|
+
/** Called after an execution completes or fails. */
|
|
62
|
+
onExecutionDone(_result: ExecutionResult): void;
|
|
63
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from '@bpinternal/zui';
|
|
2
|
+
import type { MessageMetadata } from './chat.js';
|
|
3
|
+
export type ComponentSchema = z.ZodObject<any> | z.ZodArray<any> | z.ZodEffects<any> | z.ZodPipeline<any, any>;
|
|
4
|
+
export type ComponentHandler<P extends ComponentSchema = any> = (props: z.output<P>, metadata: MessageMetadata) => Promise<void> | void;
|
|
5
|
+
export type ComponentDefinition<P extends ComponentSchema = any> = {
|
|
6
|
+
/** The exact JavaScript method name exposed on chat. */
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
props: P;
|
|
10
|
+
handler?: ComponentHandler<P>;
|
|
11
|
+
};
|
|
12
|
+
export type RenderedComponent<TProps = unknown> = {
|
|
13
|
+
readonly type: 'component';
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly props: TProps;
|
|
16
|
+
};
|
|
17
|
+
export type ComponentRegistry = ReadonlyMap<string, Component>;
|
|
18
|
+
export declare function assertValidComponent(component: unknown): asserts component is ComponentDefinition;
|
|
19
|
+
export declare class Component<P extends ComponentSchema = any> {
|
|
20
|
+
readonly definition: Readonly<ComponentDefinition<P>>;
|
|
21
|
+
readonly propsType: z.output<P>;
|
|
22
|
+
readonly handler: ComponentHandler<P> | undefined;
|
|
23
|
+
constructor(definition: ComponentDefinition<P>);
|
|
24
|
+
withHandler(handler: ComponentHandler<P>): Component<P>;
|
|
25
|
+
/** Parse once and retain an immutable delivery value. */
|
|
26
|
+
render(props: z.input<P>): RenderedComponent<z.output<P>>;
|
|
27
|
+
}
|
|
28
|
+
/** Resolve the exact methods once and share them between the prompt and runtime. */
|
|
29
|
+
export declare function createComponentRegistry(components: readonly Component[]): ComponentRegistry;
|
|
30
|
+
export declare function isComponent<P extends ComponentSchema>(rendered: unknown, component: Component<P>): rendered is RenderedComponent<z.output<P>>;
|
|
31
|
+
export declare function isAnyComponent(value: unknown): value is RenderedComponent;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from '@bpinternal/zui';
|
|
2
|
+
import { Component } from './component.js';
|
|
3
|
+
export declare const DefaultComponents: {
|
|
4
|
+
Buttons: Component<z.ZodArray<z.ZodObject<{
|
|
5
|
+
action: z.ZodDefault<z.ZodEnum<["say", "url", "postback"]>>;
|
|
6
|
+
label: z.ZodString;
|
|
7
|
+
value: z.ZodOptional<z.ZodString>;
|
|
8
|
+
url: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, "strict">, "many">>;
|
|
10
|
+
Image: Component<z.ZodObject<{
|
|
11
|
+
url: z.ZodString;
|
|
12
|
+
alt: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, "strict">>;
|
|
14
|
+
File: Component<z.ZodObject<{
|
|
15
|
+
url: z.ZodString;
|
|
16
|
+
name: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, "strict">>;
|
|
18
|
+
Video: Component<z.ZodObject<{
|
|
19
|
+
url: z.ZodString;
|
|
20
|
+
title: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, "strict">>;
|
|
22
|
+
Audio: Component<z.ZodObject<{
|
|
23
|
+
url: z.ZodString;
|
|
24
|
+
title: z.ZodOptional<z.ZodString>;
|
|
25
|
+
}, "strict">>;
|
|
26
|
+
Card: Component<z.ZodObject<{
|
|
27
|
+
title: z.ZodString;
|
|
28
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
29
|
+
text: z.ZodOptional<z.ZodString>;
|
|
30
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
31
|
+
url: z.ZodString;
|
|
32
|
+
alt: z.ZodOptional<z.ZodString>;
|
|
33
|
+
}, "strict">>;
|
|
34
|
+
buttons: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
35
|
+
action: z.ZodDefault<z.ZodEnum<["say", "url", "postback"]>>;
|
|
36
|
+
label: z.ZodString;
|
|
37
|
+
value: z.ZodOptional<z.ZodString>;
|
|
38
|
+
url: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, "strict">, "many">>;
|
|
40
|
+
}, "strict">>;
|
|
41
|
+
Carousel: Component<z.ZodObject<{
|
|
42
|
+
cards: z.ZodArray<z.ZodObject<{
|
|
43
|
+
title: z.ZodString;
|
|
44
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
45
|
+
text: z.ZodOptional<z.ZodString>;
|
|
46
|
+
image: z.ZodOptional<z.ZodObject<{
|
|
47
|
+
url: z.ZodString;
|
|
48
|
+
alt: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, "strict">>;
|
|
50
|
+
buttons: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
51
|
+
action: z.ZodDefault<z.ZodEnum<["say", "url", "postback"]>>;
|
|
52
|
+
label: z.ZodString;
|
|
53
|
+
value: z.ZodOptional<z.ZodString>;
|
|
54
|
+
url: z.ZodOptional<z.ZodString>;
|
|
55
|
+
}, "strict">, "many">>;
|
|
56
|
+
}, "strict">, "many">;
|
|
57
|
+
}, "strict">>;
|
|
58
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MessageDeltaHandler, ResponseHandler } from './chat.js';
|
|
2
|
+
export type ResponsePreset = 'markdown' | 'text' | 'speech';
|
|
3
|
+
export type Response = ResponsePreset | {
|
|
4
|
+
preset?: ResponsePreset;
|
|
5
|
+
instructions?: string;
|
|
6
|
+
handler?: ResponseHandler;
|
|
7
|
+
onDelta?: MessageDeltaHandler;
|
|
8
|
+
};
|
|
9
|
+
export type ResolvedResponse = {
|
|
10
|
+
instructions: string;
|
|
11
|
+
handler?: ResponseHandler;
|
|
12
|
+
onDelta?: MessageDeltaHandler;
|
|
13
|
+
};
|
|
14
|
+
/** Resolve one response style for the entire generation, including its stream. */
|
|
15
|
+
export declare function resolveResponse(response?: Response): ResolvedResponse;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { ToolCallEntry } from './plugins/track-tool-calls.js';
|
|
2
1
|
export declare const Identifiers: {
|
|
3
2
|
ConsoleObjIdentifier: string;
|
|
4
3
|
LineTrackingFnIdentifier: string;
|
|
5
4
|
VariableTrackingFnIdentifier: string;
|
|
6
|
-
ToolCallTrackerFnIdentifier: string;
|
|
7
|
-
ToolTrackerRetIdentifier: string;
|
|
8
5
|
CommentFnIdentifier: string;
|
|
9
6
|
};
|
|
10
7
|
export type CompiledCode = ReturnType<typeof compile>;
|
|
@@ -20,8 +17,7 @@ export declare function hasTopLevelReturn(code: string): boolean;
|
|
|
20
17
|
*
|
|
21
18
|
* 1. wraps it in an async `__fn__` so top-level `await`/`return` parse
|
|
22
19
|
* 2. instruments it in a single parse + text-edit pass:
|
|
23
|
-
* line tracking, last-line
|
|
24
|
-
* and variable tracking
|
|
20
|
+
* line tracking, last-line awaiting, comment tracing and variable tracking
|
|
25
21
|
* 3. unwraps it — the VM drivers re-wrap the bare statements themselves
|
|
26
22
|
*
|
|
27
23
|
* All edits preserve line numbers 1:1 with the wrapped source, so positions
|
|
@@ -30,7 +26,6 @@ export declare function hasTopLevelReturn(code: string): boolean;
|
|
|
30
26
|
export declare function compile(code: string): {
|
|
31
27
|
code: string;
|
|
32
28
|
codeWithMarkers: string;
|
|
33
|
-
map: import("
|
|
29
|
+
map: import("source-map-js").RawSourceMap;
|
|
34
30
|
variables: Set<string>;
|
|
35
|
-
toolCalls: Map<number, ToolCallEntry>;
|
|
36
31
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type AnyNode } from '../ast.js';
|
|
2
|
+
/**
|
|
3
|
+
* Dynamically generated source bypasses the VM's control-flow instrumentation.
|
|
4
|
+
* Reject identifiable entry points and constructor aliases. This is a language
|
|
5
|
+
* restriction, not a security boundary against reflective JavaScript escapes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function rejectDynamicCode(ast: AnyNode): void;
|
|
@@ -3,7 +3,6 @@ export declare const CommentFnIdentifier = "__comment__";
|
|
|
3
3
|
/**
|
|
4
4
|
* Replaces comments at statement position with `__comment__("<text>", <line>)`
|
|
5
5
|
* calls so the agent's inline "thinking" comments show up as traces at runtime.
|
|
6
|
-
* Comments inside expressions and the user-code markers are blanked
|
|
7
|
-
* inside instrumented tool-call ranges are left verbatim.
|
|
6
|
+
* Comments inside expressions and the user-code markers are blanked.
|
|
8
7
|
*/
|
|
9
|
-
export declare function applyCommentReplacement(ctx: Ctx
|
|
8
|
+
export declare function applyCommentReplacement(ctx: Ctx): void;
|
|
@@ -6,11 +6,12 @@ export type LastLineEdit = {
|
|
|
6
6
|
suffix: string;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* return a pending Promise):
|
|
9
|
+
* Awaits the last expression without changing whether the program returns it.
|
|
10
|
+
* The isolated VM cannot return a pending Promise:
|
|
12
11
|
* - `return expr` → `return await (expr)`
|
|
13
|
-
* - a trailing `call()` / `await call()` statement → `
|
|
12
|
+
* - a trailing `call()` / `await call()` statement → `await (…)`
|
|
13
|
+
*
|
|
14
|
+
* Discarded values must stay discarded, especially terminal decision receipts.
|
|
14
15
|
*
|
|
15
16
|
* The prefix must be applied before, and the suffix after, all other edits so
|
|
16
17
|
* they wrap around the tool-call instrumentation.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Ctx } from '../ast.js';
|
|
2
|
+
export declare const TerminationGuardIdentifier = "__llmz_guard";
|
|
3
|
+
export declare const TerminationCheckpointIdentifier = "__llmz_checkpoint";
|
|
4
|
+
/**
|
|
5
|
+
* A terminal host call unwinds ordinary JavaScript. User error handlers must not
|
|
6
|
+
* consume that control flow, and async continuations must check before resuming.
|
|
7
|
+
*/
|
|
8
|
+
export declare function applyTerminationGuards(ctx: Ctx): () => void;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { type Ctx } from '../ast.js';
|
|
2
2
|
export declare const VariableTrackingFnIdentifier = "__var__";
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
* - after each variable declaration: `__var__("a", () => eval("a"));`
|
|
6
|
-
* - at the top of function bodies, for their parameters
|
|
7
|
-
*
|
|
8
|
-
* The `eval` indirection captures the variable lazily in its own scope.
|
|
9
|
-
*/
|
|
10
|
-
export declare function applyVariableTracking(ctx: Ctx, variables: Set<string>): void;
|
|
3
|
+
/** Capture only session-level bindings, and record completed writes without changing expression values. */
|
|
4
|
+
export declare function applyVariableTracking(ctx: Ctx, variables: Set<string>, deferSuffixes?: boolean): () => void;
|