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
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ExecutionResult } from '../result.js';
|
|
2
|
-
import { ExecutionProps } from './types.js';
|
|
3
|
-
|
|
2
|
+
import type { ExecutionProps } from './types.js';
|
|
3
|
+
/** Each iteration joins generation and execution before settling its transcript. */
|
|
4
|
+
export declare function executeContext(props: ExecutionProps): Promise<ExecutionResult>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Iteration } from '../context.js';
|
|
2
|
+
import { type InspectionIdentity, type Inspector } from '../inspection.js';
|
|
3
|
+
import type { Traces } from '../types.js';
|
|
4
|
+
export type ExecutionActivity = {
|
|
5
|
+
calls: Traces.ToolCall[];
|
|
6
|
+
deliveries: Traces.MessageDelivery[];
|
|
7
|
+
};
|
|
8
|
+
/** Collect recorded operations, excluding ordinary assistant text delivery. */
|
|
9
|
+
export declare function getExecutionActivity(iteration: Iteration): ExecutionActivity;
|
|
10
|
+
export declare function renderToolCalls(activity: ExecutionActivity, includeRecoveryValues?: boolean, inspector?: Inspector, identity?: InspectionIdentity): string | undefined;
|
|
11
|
+
export declare function renderMessageDeliveries({ deliveries }: ExecutionActivity, cancelled?: boolean, inspector?: Inspector, identity?: InspectionIdentity): string | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { InspectionIdentity, Inspector } from '../inspection.js';
|
|
2
|
+
import type { TruncatePreserve } from '../truncate.js';
|
|
3
|
+
/** XML-style boundaries keep diagnostic text separate from recovery instructions. */
|
|
4
|
+
export declare function reportSection(name: string, content: string, maxTokens?: number, options?: {
|
|
5
|
+
heading?: string;
|
|
6
|
+
preserve?: TruncatePreserve;
|
|
7
|
+
}): string;
|
|
8
|
+
/** Show the specific failure and guest source, never the host's implementation stack. */
|
|
9
|
+
export declare function renderExecutionDiagnostics(error: unknown, message: string, inspector: Inspector, identity: InspectionIdentity): string[];
|
|
10
|
+
/** Keep failure sites visible even when they are near the end of a long program. */
|
|
11
|
+
export declare function renderSourceTrace(stack: string, inspector: Inspector, identity: InspectionIdentity): string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type InspectionPolicyLookup } from '../inspect.js';
|
|
2
|
+
import { type InspectionIdentity, type Inspector } from '../inspection.js';
|
|
3
|
+
import type { MemoryReport } from '../session/memory.js';
|
|
4
|
+
import { type ExecutionActivity } from './execution-activity.js';
|
|
5
|
+
import { type ForcedInspection } from './forced-inspection.js';
|
|
6
|
+
export { renderMessageDeliveries } from './execution-activity.js';
|
|
7
|
+
export type ExecutionOutcome = {
|
|
8
|
+
type: 'inspect';
|
|
9
|
+
value: unknown;
|
|
10
|
+
available: boolean;
|
|
11
|
+
explicit: boolean;
|
|
12
|
+
forcedInspections?: readonly ForcedInspection[];
|
|
13
|
+
downstreamError?: unknown;
|
|
14
|
+
} | {
|
|
15
|
+
type: 'exit';
|
|
16
|
+
name: string;
|
|
17
|
+
value: unknown;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'error';
|
|
20
|
+
message: string;
|
|
21
|
+
error?: unknown;
|
|
22
|
+
exitName?: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'cancelled';
|
|
25
|
+
message: string;
|
|
26
|
+
} | {
|
|
27
|
+
type: 'interrupted';
|
|
28
|
+
reason: 'stream' | 'thinking';
|
|
29
|
+
message?: string;
|
|
30
|
+
context?: unknown;
|
|
31
|
+
stacktrace?: string;
|
|
32
|
+
};
|
|
33
|
+
export type ExecutionReport = {
|
|
34
|
+
outcome: ExecutionOutcome;
|
|
35
|
+
activity: ExecutionActivity;
|
|
36
|
+
memory: MemoryReport;
|
|
37
|
+
source?: {
|
|
38
|
+
requested?: string;
|
|
39
|
+
executed?: string;
|
|
40
|
+
};
|
|
41
|
+
requiresExit?: boolean;
|
|
42
|
+
iteration?: number;
|
|
43
|
+
identity?: InspectionIdentity;
|
|
44
|
+
inspector?: Inspector;
|
|
45
|
+
maxTokens?: number;
|
|
46
|
+
policies?: InspectionPolicyLookup;
|
|
47
|
+
};
|
|
48
|
+
/** Format one settled outcome; execution is responsible for deciding what happened. */
|
|
49
|
+
export declare function renderExecutionReport({ outcome, activity, memory, source, requiresExit, iteration, identity, inspector, maxTokens, policies, }: ExecutionReport): string;
|
|
50
|
+
/** Keep the requested assistant call intact while disclosing the source the host actually ran. */
|
|
51
|
+
export declare function renderExecutionOverride(executedCode?: string, requestedCode?: string, inspector?: Inspector, identity?: InspectionIdentity): string | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Chat, type ChatMessage, type MessageDeltaHandler, type MessageMetadata } from '../../chat/chat.js';
|
|
2
|
+
import type { Component } from '../../chat/component.js';
|
|
3
|
+
/** Collect both delivery paths when testing execution order and receipts. */
|
|
4
|
+
export declare function createRecordingChat({ handler, onMessageDelta, components, }: {
|
|
5
|
+
handler: (message: ChatMessage, metadata: MessageMetadata) => Promise<void> | void;
|
|
6
|
+
onMessageDelta?: MessageDeltaHandler;
|
|
7
|
+
components?: Component[];
|
|
8
|
+
}): Chat;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CognitiveMetadata, CognitiveResponse, CognitiveStreamChunk, CognitiveToolCall } from '@botpress/cognitive';
|
|
2
|
+
import { _CustomModelClient, type RuntimeGenerateContentInput } from '../../custom-client.js';
|
|
3
|
+
export declare const nativeMetadata: CognitiveMetadata;
|
|
4
|
+
export declare const nativeCall: (name: string, input?: Record<string, unknown>, id?: string) => CognitiveToolCall;
|
|
5
|
+
export declare const javascript: (code: string) => CognitiveResponse;
|
|
6
|
+
export declare const response: (output?: string, toolCalls?: CognitiveToolCall[]) => CognitiveResponse;
|
|
7
|
+
export declare class NativeClient extends _CustomModelClient {
|
|
8
|
+
responses: CognitiveResponse[];
|
|
9
|
+
requests: RuntimeGenerateContentInput[];
|
|
10
|
+
constructor(responses: CognitiveResponse[]);
|
|
11
|
+
getModelDetails(id: string): Promise<{
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
input: {
|
|
16
|
+
maxTokens: number;
|
|
17
|
+
costPer1MTokens: number;
|
|
18
|
+
};
|
|
19
|
+
output: {
|
|
20
|
+
maxTokens: number;
|
|
21
|
+
costPer1MTokens: number;
|
|
22
|
+
};
|
|
23
|
+
tags: never[];
|
|
24
|
+
lifecycle: 'production';
|
|
25
|
+
}>;
|
|
26
|
+
generateText(input: RuntimeGenerateContentInput): Promise<CognitiveResponse>;
|
|
27
|
+
}
|
|
28
|
+
export declare class NativeStreamClient extends NativeClient {
|
|
29
|
+
size: number;
|
|
30
|
+
probe: () => void;
|
|
31
|
+
constructor(responses: CognitiveResponse[], size?: number, probe?: () => void);
|
|
32
|
+
generateTextStream(input: RuntimeGenerateContentInput): AsyncGenerator<CognitiveStreamChunk>;
|
|
33
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Synthetic multilingual inputs
|
|
1
|
+
/** Synthetic multilingual inputs for native protocol boundary tests. */
|
|
2
2
|
export declare const protocolLanguages: readonly [{
|
|
3
3
|
readonly language: 'English';
|
|
4
4
|
readonly hello: 'Hello!';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type InspectionPolicyLookup } from '../inspect.js';
|
|
2
|
+
import type { InspectionIdentity, Inspector } from '../inspection.js';
|
|
3
|
+
/** A successful business result that must be shown before this turn may complete. */
|
|
4
|
+
export type ForcedInspection = {
|
|
5
|
+
tool: string;
|
|
6
|
+
toolCallId: string;
|
|
7
|
+
line?: number;
|
|
8
|
+
reason: string;
|
|
9
|
+
value: unknown;
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
|
+
};
|
|
12
|
+
/** Keep attribution and content together, using the same display budgets as inspect(). */
|
|
13
|
+
export declare function renderForcedInspection(inspections: readonly ForcedInspection[], inspector: Inspector, identity: InspectionIdentity, maxTokens: number, policies?: InspectionPolicyLookup): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
import { RuntimeCognitive } from './types.js';
|
|
1
|
+
import type { CognitiveMessage, CognitiveMetadata, CognitiveResponse, CognitiveToolCall } from '@botpress/cognitive';
|
|
2
|
+
import type { MessageDelta, MessageMetadata } from '../chat/chat.js';
|
|
3
|
+
import type { Context, Iteration } from '../context.js';
|
|
4
|
+
import type { ExecutionHooks, RuntimeCognitive } from './types.js';
|
|
5
|
+
export { countNativeRequestTokens } from './token-budget.js';
|
|
6
|
+
/** A custom provider adapter can return the full assistant message, including opaque continuation data. */
|
|
7
|
+
export type NativeResponse = CognitiveResponse & {
|
|
8
|
+
assistantMessage?: CognitiveMessage;
|
|
9
|
+
continuation?: unknown;
|
|
10
|
+
};
|
|
11
|
+
export type NativeGeneration = {
|
|
12
|
+
attempt: number;
|
|
13
|
+
output: string;
|
|
14
|
+
toolCalls: CognitiveToolCall[];
|
|
15
|
+
assistantMessage?: CognitiveMessage;
|
|
16
|
+
continuation?: unknown;
|
|
17
|
+
metadata: CognitiveMetadata;
|
|
18
|
+
messageMetadata: MessageMetadata;
|
|
19
|
+
};
|
|
5
20
|
type GenerateCodeProps = {
|
|
6
21
|
iteration: Iteration;
|
|
7
22
|
ctx: Context;
|
|
8
23
|
cognitive: RuntimeCognitive;
|
|
9
24
|
controller: AbortController;
|
|
10
25
|
metadata?: Record<string, string>;
|
|
11
|
-
/**
|
|
12
|
-
* Called for each send after a complete, valid response and successful transport.
|
|
13
|
-
*/
|
|
14
|
-
onSend?: (send: ParsedSend, metadata: MessageMetadata) => Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* Called for each `■send` body chunk as it is parsed from the stream
|
|
17
|
-
* (streaming clients only), or with a restart delta before replacement output.
|
|
18
|
-
* Text errors are best-effort; restart errors terminate generation.
|
|
19
|
-
*/
|
|
20
26
|
onSendDelta?: (delta: MessageDelta) => Promise<void> | void;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
onRunStart?: () => void;
|
|
27
|
+
onBeforeRequest?: ExecutionHooks['onBeforeRequest'];
|
|
28
|
+
/** Start a complete normalized call without waiting for execution or the stream tail. */
|
|
29
|
+
onToolCalls?: (calls: CognitiveToolCall[]) => boolean;
|
|
26
30
|
};
|
|
27
|
-
export declare
|
|
28
|
-
export {};
|
|
31
|
+
export declare function generateCode({ iteration, ctx, cognitive, controller, metadata, onSendDelta, onToolCalls, onBeforeRequest, }: GenerateCodeProps): Promise<NativeGeneration>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { InspectionPolicyLookup } from '../inspect.js';
|
|
2
|
+
import type { TruncationPolicy } from '../truncate.js';
|
|
3
|
+
/** Explicit display policies apply only to unchanged values in this JavaScript execution. */
|
|
4
|
+
export declare class InspectionValues {
|
|
5
|
+
private readonly _primitives;
|
|
6
|
+
private readonly _objects;
|
|
7
|
+
capture(value: unknown, policy: TruncationPolicy): void;
|
|
8
|
+
captureDefault(value: unknown, maxTokens: number): void;
|
|
9
|
+
private _register;
|
|
10
|
+
/** Match unchanged VM copies without rebuilding a wrapped display graph. */
|
|
11
|
+
readonly getPolicy: InspectionPolicyLookup;
|
|
12
|
+
private _objectKey;
|
|
13
|
+
private _mergePolicy;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ComponentRegistry, RenderedComponent } from '../chat/component.js';
|
|
2
|
+
import type { Iteration } from '../context.js';
|
|
3
|
+
import { ThinkSignal } from '../errors.js';
|
|
4
|
+
import type { Exit } from '../exit.js';
|
|
5
|
+
import type { ForcedInspection } from './forced-inspection.js';
|
|
6
|
+
/** A child message keeps its identity from preparation through acknowledged delivery. */
|
|
7
|
+
export type PreparedMessage = {
|
|
8
|
+
id: string;
|
|
9
|
+
component: RenderedComponent;
|
|
10
|
+
};
|
|
11
|
+
export type JavaScriptOutcome = {
|
|
12
|
+
type: 'inspect';
|
|
13
|
+
value: unknown;
|
|
14
|
+
} | {
|
|
15
|
+
type: 'exit';
|
|
16
|
+
exit: Exit;
|
|
17
|
+
value: unknown;
|
|
18
|
+
};
|
|
19
|
+
type DecisionReceipt = Readonly<{
|
|
20
|
+
__llmz_decision: string;
|
|
21
|
+
}>;
|
|
22
|
+
type TerminalOutcome = Extract<JavaScriptOutcome, {
|
|
23
|
+
type: 'exit';
|
|
24
|
+
}>;
|
|
25
|
+
export type JavaScriptBindings = {
|
|
26
|
+
exit(name?: string, value?: unknown): never;
|
|
27
|
+
inspect(value: unknown): DecisionReceipt;
|
|
28
|
+
chat: Readonly<Record<string, (input: unknown) => void>>;
|
|
29
|
+
};
|
|
30
|
+
export type JavaScriptApi = {
|
|
31
|
+
bindings: JavaScriptBindings;
|
|
32
|
+
resolve(value: unknown): JavaScriptOutcome | undefined;
|
|
33
|
+
isReceipt(value: unknown): boolean;
|
|
34
|
+
getTerminalOutcome(): TerminalOutcome | undefined;
|
|
35
|
+
/** The first host interruption closes execution before guest handlers can consume it. */
|
|
36
|
+
getInterruption(): ThinkSignal | undefined;
|
|
37
|
+
requestInspection(inspection: ForcedInspection): void;
|
|
38
|
+
getForcedInspections(): readonly ForcedInspection[];
|
|
39
|
+
throwIfTerminated(): void;
|
|
40
|
+
track<T>(operation: () => Promise<T>): Promise<T>;
|
|
41
|
+
assertOpen(): void;
|
|
42
|
+
/** Record validation failures and close host operations on critical configuration errors. */
|
|
43
|
+
reportError(error: unknown): void;
|
|
44
|
+
/** Called at program settlement, before background work can invoke another host operation. */
|
|
45
|
+
complete(): void;
|
|
46
|
+
/** Joins automatic message delivery and business work before the iteration can settle. */
|
|
47
|
+
close(): Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
type JavaScriptApiOptions = {
|
|
50
|
+
iteration: Pick<Iteration, 'id' | 'nativeCallId'>;
|
|
51
|
+
components: ComponentRegistry;
|
|
52
|
+
exits: readonly Exit[];
|
|
53
|
+
deliver(messages: readonly PreparedMessage[]): Promise<void>;
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
onError?(error: unknown): void;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Component methods send synchronously; the runtime joins delivery in close().
|
|
59
|
+
* Inspection returns a decision, while exit latches an outcome and stops the program.
|
|
60
|
+
*/
|
|
61
|
+
export declare function createJavaScriptApi({ iteration, components, exits, deliver, signal, onError, }: JavaScriptApiOptions): JavaScriptApi;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CognitiveTool, CognitiveToolCall } from '@botpress/cognitive';
|
|
2
|
+
export declare const WORKER_RESPONSE_INSTRUCTION = "You are running in worker mode. Respond only with a run_javascript tool call. Keep assistant text empty: do not send messages, preambles, progress updates, explanations, acknowledgements such as \"Done\", Markdown, or JSON outside the tool call. This applies before and after tools, during recovery, and when completing the task.";
|
|
3
|
+
export declare const RUN_JAVASCRIPT_TOOL: CognitiveTool;
|
|
4
|
+
/** Select delivery guidance without changing the native tool name or input schema. */
|
|
5
|
+
export declare function getRunJavaScriptTool(chat: boolean): CognitiveTool;
|
|
6
|
+
export type ValidatedNativeCall = {
|
|
7
|
+
id: string;
|
|
8
|
+
code: string;
|
|
9
|
+
};
|
|
10
|
+
export type NativeCallValidation = {
|
|
11
|
+
valid: true;
|
|
12
|
+
call?: ValidatedNativeCall;
|
|
13
|
+
} | {
|
|
14
|
+
valid: false;
|
|
15
|
+
errors: string[];
|
|
16
|
+
};
|
|
17
|
+
/** Validate the entire response before any delivery or business action begins. */
|
|
18
|
+
export declare function validateNativeToolCalls(calls: readonly CognitiveToolCall[]): NativeCallValidation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CognitiveMessage } from '@botpress/cognitive';
|
|
2
|
+
/**
|
|
3
|
+
* Estimate text, structured arguments, schemas, and message scaffolding. Media
|
|
4
|
+
* URLs carry bytes or locations, not model text. Cognitive does not expose a
|
|
5
|
+
* media-token estimator; actual media usage is reported by the provider.
|
|
6
|
+
*/
|
|
7
|
+
export declare function countNativeRequestTokens(messages: CognitiveMessage[], tools: unknown): number;
|
|
8
|
+
type ModelLimits = {
|
|
9
|
+
input: {
|
|
10
|
+
maxTokens: number;
|
|
11
|
+
};
|
|
12
|
+
output: {
|
|
13
|
+
maxTokens: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
/** Reserve output space within every model that can receive this request. */
|
|
17
|
+
export declare function resolveTokenBudget(model: ModelLimits | readonly ModelLimits[], maxTokens?: number): {
|
|
18
|
+
limit: number;
|
|
19
|
+
output: number;
|
|
20
|
+
input: number;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { Chat } from '../chat.js';
|
|
2
1
|
import { Iteration } from '../context.js';
|
|
3
2
|
import { type Tool } from '../tool.js';
|
|
4
|
-
import {
|
|
3
|
+
import { type TruncationPolicy } from '../truncate.js';
|
|
4
|
+
import type { ForcedInspection } from './forced-inspection.js';
|
|
5
5
|
import { ExecutionHooks } from './types.js';
|
|
6
6
|
type ToolWrapperProps = {
|
|
7
|
-
chat?: Chat;
|
|
8
7
|
tool: Tool;
|
|
9
8
|
object?: string;
|
|
10
|
-
traces: Trace[];
|
|
11
9
|
iteration: Iteration;
|
|
12
10
|
beforeHook?: ExecutionHooks['onBeforeTool'];
|
|
13
11
|
afterHook?: ExecutionHooks['onAfterTool'];
|
|
12
|
+
onTruncation?: (value: unknown, policy: TruncationPolicy) => void;
|
|
13
|
+
onResult?: (value: unknown) => void;
|
|
14
14
|
controller: AbortController;
|
|
15
|
+
onThink?: (inspection: ForcedInspection) => void;
|
|
15
16
|
};
|
|
16
|
-
export declare function wrapTool({
|
|
17
|
+
export declare function wrapTool({ tool, object, iteration, beforeHook, afterHook, onTruncation, onResult, controller, onThink, }: ToolWrapperProps): (input: any, line?: number) => Promise<any>;
|
|
17
18
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Cognitive, type BotpressClientLike, Models, type SttModels } from '@botpress/cognitive';
|
|
2
|
-
import { Chat } from '../chat.js';
|
|
1
|
+
import { Cognitive, type CognitiveMessage, type BotpressClientLike, Models, type SttModels } from '@botpress/cognitive';
|
|
2
|
+
import { Chat } from '../chat/chat.js';
|
|
3
3
|
import { Context, Iteration } from '../context.js';
|
|
4
4
|
import { _CustomModelClient } from '../custom-client.js';
|
|
5
|
-
import type { Example } from '../example.js';
|
|
6
5
|
import { Exit, ExitResult } from '../exit.js';
|
|
7
6
|
import { ValueOrGetter } from '../getter.js';
|
|
7
|
+
import type { OnInspect } from '../inspection.js';
|
|
8
8
|
import { type ObjectInstance } from '../objects.js';
|
|
9
|
-
import {
|
|
9
|
+
import type { Session } from '../session/session.js';
|
|
10
10
|
import { type Tool } from '../tool.js';
|
|
11
11
|
import { Trace } from '../types.js';
|
|
12
12
|
export type ExecutionHooks = {
|
|
@@ -31,9 +31,21 @@ export type ExecutionHooks = {
|
|
|
31
31
|
* This hook will block the execution of the iteration until it resolves.
|
|
32
32
|
*
|
|
33
33
|
* This hook will be called before each iteration starts, regardless of the status.
|
|
34
|
-
*
|
|
34
|
+
* Use this for observation. Configure dynamic model arguments with their getters.
|
|
35
35
|
*/
|
|
36
|
-
onIterationStart?: (iteration: Iteration, controller: AbortController, context: Context) => Promise<void |
|
|
36
|
+
onIterationStart?: (iteration: Iteration, controller: AbortController, context: Context) => Promise<void> | void;
|
|
37
|
+
/** Customize the assembled request after compaction. Custom messages must fit the context budget. */
|
|
38
|
+
onBeforeRequest?: (event: {
|
|
39
|
+
messages: CognitiveMessage[];
|
|
40
|
+
iteration: Iteration;
|
|
41
|
+
controller: AbortController;
|
|
42
|
+
}) => Promise<{
|
|
43
|
+
messages: CognitiveMessage[];
|
|
44
|
+
} | void> | {
|
|
45
|
+
messages: CognitiveMessage[];
|
|
46
|
+
} | void;
|
|
47
|
+
/** Format runtime values; LLMz enforces the supplied budget on custom output. */
|
|
48
|
+
onInspect?: OnInspect;
|
|
37
49
|
/**
|
|
38
50
|
* BLOCKING HOOK
|
|
39
51
|
* This hook will block the execution of the iteration until it resolves.
|
|
@@ -84,6 +96,8 @@ export type ExecutionHooks = {
|
|
|
84
96
|
input: any;
|
|
85
97
|
controller: AbortController;
|
|
86
98
|
toolCallId: string;
|
|
99
|
+
/** Native run_javascript call owning this business call. */
|
|
100
|
+
nativeCallId?: string;
|
|
87
101
|
object?: string;
|
|
88
102
|
}) => Promise<{
|
|
89
103
|
input?: any;
|
|
@@ -104,18 +118,33 @@ export type ExecutionHooks = {
|
|
|
104
118
|
output: any;
|
|
105
119
|
controller: AbortController;
|
|
106
120
|
toolCallId: string;
|
|
121
|
+
/** Native run_javascript call owning this business call. */
|
|
122
|
+
nativeCallId?: string;
|
|
107
123
|
object?: string;
|
|
108
124
|
}) => Promise<{
|
|
109
125
|
output?: any;
|
|
110
126
|
} | void>;
|
|
111
127
|
};
|
|
112
128
|
type Options = Partial<Pick<Context, 'loop' | 'timeout'>> & {
|
|
129
|
+
/**
|
|
130
|
+
* Require the assistant to be the last participant who spoke before the built-in
|
|
131
|
+
* ListenExit can complete. Defaults to true. Successful text and component delivery
|
|
132
|
+
* count across iterations and executions; events and tool results do not.
|
|
133
|
+
* Set false for intentionally silent chat handling. Custom exits and workers
|
|
134
|
+
* are unaffected. Rejection is recoverable within the remaining loop budget.
|
|
135
|
+
*/
|
|
136
|
+
requireChatResponse?: boolean;
|
|
113
137
|
/**
|
|
114
138
|
* Optional cap on the model's context window, in tokens.
|
|
115
|
-
* The effective limit is `min(maxTokens, model
|
|
139
|
+
* The effective limit is `min(maxTokens, smallest configured model input limit)`.
|
|
116
140
|
* Useful to reduce cost and latency on models with very large context windows.
|
|
117
141
|
*/
|
|
118
142
|
maxTokens?: number;
|
|
143
|
+
/**
|
|
144
|
+
* Default inspection budget for tool results, from 0 to 2,000 tokens.
|
|
145
|
+
* Defaults to 2,000. A tool's truncate() wrapper can override this limit.
|
|
146
|
+
*/
|
|
147
|
+
toolResultMaxTokens?: number;
|
|
119
148
|
/**
|
|
120
149
|
* Maximum time to wait for the first streamed token, in milliseconds, before
|
|
121
150
|
* the cognitive service falls back to the next model/provider. Only applies
|
|
@@ -126,8 +155,9 @@ type Options = Partial<Pick<Context, 'loop' | 'timeout'>> & {
|
|
|
126
155
|
/**
|
|
127
156
|
* Allow Cognitive to restart a failed stream on another model. Previews remain
|
|
128
157
|
* live and are retracted with a restart delta before replacement output.
|
|
129
|
-
*
|
|
130
|
-
*
|
|
158
|
+
* Complete calls may execute while transport is open. Once execution starts,
|
|
159
|
+
* a stream failure or restart ends the iteration without replaying its effects.
|
|
160
|
+
* Streaming-only; defaults to false.
|
|
131
161
|
*/
|
|
132
162
|
midStreamFallback?: boolean;
|
|
133
163
|
/**
|
|
@@ -138,13 +168,15 @@ type Options = Partial<Pick<Context, 'loop' | 'timeout'>> & {
|
|
|
138
168
|
transcriptionModel?: SttModels;
|
|
139
169
|
};
|
|
140
170
|
export type ExecutionProps = {
|
|
171
|
+
/** Append input to this session before execution. Retains history, queued input, and JavaScript memory. */
|
|
172
|
+
session?: Session;
|
|
141
173
|
/**
|
|
142
174
|
* If provided, the execution will be run in "Chat Mode".
|
|
143
|
-
*
|
|
175
|
+
* Chat configures assistant text and rich component delivery. Conversation input belongs to the session.
|
|
144
176
|
* The execution can still end with a custom Exit, but a special ListenExit will be added to give back the chat control to the user.
|
|
145
177
|
*
|
|
146
|
-
* If `chat` is not provided, the execution will run in "Worker Mode"
|
|
147
|
-
* In Worker Mode, the execution
|
|
178
|
+
* If `chat` is not provided, the execution will run in "Worker Mode" without chat delivery.
|
|
179
|
+
* In Worker Mode, the execution uses the same session history and memory, and iterates until an Exit or its limit.
|
|
148
180
|
*/
|
|
149
181
|
chat?: Chat;
|
|
150
182
|
/**
|
|
@@ -154,14 +186,6 @@ export type ExecutionProps = {
|
|
|
154
186
|
* Dynamic instructions are evaluated at the start of each iteration, allowing for context-aware instructions.
|
|
155
187
|
*/
|
|
156
188
|
instructions?: ValueOrGetter<string, Context>;
|
|
157
|
-
/**
|
|
158
|
-
* Labeled examples of one situation and one response, kept outside the live transcript.
|
|
159
|
-
* Use `new Example({ situation, code })` or `new Example({ situation, messages, exit })`.
|
|
160
|
-
* Evaluated each iteration, like instructions. Examples must use the current
|
|
161
|
-
* component/exit catalog. They are kept intact when the prompt is truncated;
|
|
162
|
-
* select a small relevant set to leave room for tools and conversation.
|
|
163
|
-
*/
|
|
164
|
-
examples?: ValueOrGetter<Example[], Context>;
|
|
165
189
|
/**
|
|
166
190
|
* Objects available in the context.
|
|
167
191
|
* Objects are useful to scope related tools together and to provide data to the VM.
|
|
@@ -194,7 +218,7 @@ export type ExecutionProps = {
|
|
|
194
218
|
* Exits define the possible endpoints for the execution. Every execution will either end with an exit, or run out of iterations.
|
|
195
219
|
*
|
|
196
220
|
* When `chat` is provided, the built-in "ListenExit" is automatically added.
|
|
197
|
-
*
|
|
221
|
+
* In worker mode, omitting `exits` adds the built-in "DefaultExit". An explicit empty array provides no exits.
|
|
198
222
|
*
|
|
199
223
|
* Each exit has a name and can have aliases, which are alternative names for the exit that can be used to call it.
|
|
200
224
|
* Exits can also have a Zui schema to validate the return value when the exit is reached.
|
|
@@ -216,14 +240,6 @@ export type ExecutionProps = {
|
|
|
216
240
|
* Aborted iterations will end with IterationStatuses.Aborted and the execution will be marked as failed.
|
|
217
241
|
*/
|
|
218
242
|
signal?: AbortSignal;
|
|
219
|
-
/**
|
|
220
|
-
* A snapshot is a saved state of the execution context.
|
|
221
|
-
* It can be used to resume the execution of a context at a later time.
|
|
222
|
-
* This is useful for long-running executions that may need to be paused and resumed later.
|
|
223
|
-
* The snapshot MUST be settled, which means it has to be resolved or rejected.
|
|
224
|
-
* Providing an unsettled snapshot will throw an error.
|
|
225
|
-
*/
|
|
226
|
-
snapshot?: Snapshot;
|
|
227
243
|
/**
|
|
228
244
|
* The model to use for the LLM.
|
|
229
245
|
* This can be a static model name or a function that returns a model name based on the current context.
|
|
@@ -252,8 +268,8 @@ export type ExecutionProps = {
|
|
|
252
268
|
} & ExecutionHooks;
|
|
253
269
|
export type RuntimeCognitive = Pick<Cognitive, 'getModelDetails' | 'generateText'> & {
|
|
254
270
|
/**
|
|
255
|
-
* Streaming generation.
|
|
256
|
-
*
|
|
271
|
+
* Streaming generation. Assistant text streams as provisional previews; native
|
|
272
|
+
* tool calls can execute while text streams; both settle before the next iteration.
|
|
257
273
|
*/
|
|
258
274
|
generateTextStream?: Cognitive['generateTextStream'];
|
|
259
275
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Context, Iteration } from '../context.js';
|
|
2
|
+
import type { TruncationPolicy } from '../truncate.js';
|
|
2
3
|
import { type VMContext } from '../vm/types.js';
|
|
4
|
+
import type { JavaScriptApi } from './javascript-api.js';
|
|
3
5
|
import { ExecutionHooks } from './types.js';
|
|
4
6
|
type BuildVMContextProps = {
|
|
5
7
|
ctx: Context;
|
|
@@ -7,6 +9,9 @@ type BuildVMContextProps = {
|
|
|
7
9
|
controller: AbortController;
|
|
8
10
|
onBeforeTool?: ExecutionHooks['onBeforeTool'];
|
|
9
11
|
onAfterTool?: ExecutionHooks['onAfterTool'];
|
|
12
|
+
onTruncation?: (value: unknown, policy: TruncationPolicy) => void;
|
|
13
|
+
onToolResult?: (value: unknown) => void;
|
|
14
|
+
javascriptApi?: JavaScriptApi;
|
|
10
15
|
};
|
|
11
|
-
export declare const buildVMContext: ({ ctx, iteration, controller, onBeforeTool, onAfterTool, }: BuildVMContextProps) => VMContext;
|
|
16
|
+
export declare const buildVMContext: ({ ctx, iteration, controller, onBeforeTool, onAfterTool, onTruncation, onToolResult, javascriptApi, }: BuildVMContextProps) => VMContext;
|
|
12
17
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Runtime bindings are never tool names or retained user variables. */
|
|
2
|
+
export declare const RUNTIME_BINDING_NAMES: readonly ['$return', '$iterations', 'exit', 'inspect', 'chat'];
|
|
3
|
+
export declare const TERMINATION_BINDING_NAMES: readonly ['__llmz_guard', '__llmz_checkpoint', '__llmz_missing_tool'];
|
|
4
|
+
export declare const RESERVED_RUNTIME_NAMES: ReadonlySet<string>;
|