llmz 0.8.0 → 1.0.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/DOCS.md +230 -1796
- package/ERRORS.md +98 -0
- package/README.md +96 -548
- 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-BpMVZYOa.cjs +649 -0
- package/dist/component-C27qu6Zv.js +614 -0
- package/dist/context.d.ts +74 -385
- package/dist/custom-client-BDkgBR2w.js +1631 -0
- package/dist/custom-client-MytucGI-.cjs +1708 -0
- package/dist/custom-client.d.ts +12 -2
- package/dist/errors/catalog.d.ts +287 -0
- package/dist/errors/hooks.d.ts +2 -0
- package/dist/errors-H4JJFH3S.js +620 -0
- package/dist/errors-IhnTKUp7.cjs +871 -0
- package/dist/errors.d.ts +18 -36
- package/dist/execute-BYI_U5sR.js +1943 -0
- package/dist/execute-DLas4V2n.cjs +1944 -0
- package/dist/{exit-DUM96DN1.cjs → exit-BUgJ5qi5.cjs} +38 -28
- package/dist/{exit-CDdxDBRT.js → exit-CPNk3vbz.js} +37 -27
- package/dist/exit.d.ts +19 -16
- package/dist/index.cjs +181 -999
- package/dist/index.d.ts +25 -28
- package/dist/index.js +141 -974
- package/dist/index.workerd.js +7725 -9531
- package/dist/inspect.d.ts +19 -3
- package/dist/inspection.d.ts +38 -0
- package/dist/native-Bm6L9zOb.cjs +212 -0
- package/dist/native-DvTH9vFe.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 -98
- package/dist/quickjs-variant-DJwYDSsb.cjs +1073 -0
- package/dist/quickjs-variant-DlPi9-Sx.js +984 -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-activity.test.d.ts +1 -0
- package/dist/runtime/execution-diagnostics.d.ts +11 -0
- package/dist/runtime/execution-diagnostics.test.d.ts +1 -0
- package/dist/runtime/execution-report.d.ts +48 -0
- package/dist/runtime/execution-report.test.d.ts +1 -0
- package/dist/runtime/execution-safety.test.d.ts +1 -0
- package/dist/runtime/exit-control-flow.test.d.ts +1 -0
- package/dist/runtime/fixtures/chat.d.ts +8 -0
- package/dist/runtime/fixtures/long-search.d.ts +19 -0
- package/dist/runtime/fixtures/long-search.test.d.ts +1 -0
- package/dist/runtime/fixtures/native-client.d.ts +33 -0
- package/dist/runtime/fixtures/protocol-languages.d.ts +74 -0
- package/dist/runtime/generate.d.ts +23 -27
- 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 +59 -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/protocol-adherence.test.d.ts +1 -0
- package/dist/runtime/single-tool.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 +4 -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 +41 -36
- 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-Aer_W7Al.js +45 -0
- package/dist/schema-DBkjo0b7.cjs +68 -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 +17 -0
- package/dist/session/messages.test.d.ts +1 -0
- package/dist/session/serialization.d.ts +34 -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 +117 -0
- package/dist/session/session.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--gK91eez.js} +144 -92
- package/dist/{tool-Dy6AJpJH.cjs → tool-Da_F-N-5.cjs} +146 -94
- package/dist/tool.d.ts +25 -17
- package/dist/truncate-BSoH2-nY.js +79 -0
- package/dist/truncate-nV3Mxr6-.cjs +102 -0
- package/dist/truncate.d.ts +24 -0
- package/dist/truncate.test.d.ts +1 -0
- package/dist/types.d.ts +27 -9
- package/dist/{typings-3lsqCbkn.cjs → typings-C1ihexWE.cjs} +38 -193
- package/dist/{typings-CrBa7Tyy.js → typings-D9_aC8aq.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 +18 -3
- package/dist/{vm-BLsHw1da.js → vm-8jxt8PTK.js} +1162 -180
- package/dist/{vm-D6s1zF6M.cjs → vm-XuVPuW3Y.cjs} +1195 -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-DdArNQhl.cjs +0 -643
- package/dist/common-pgJjFu2Y.js +0 -596
- 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-BXS8vAwO.cjs +0 -73
- package/dist/component-Dq7ZLdvy.js +0 -44
- package/dist/component.d.ts +0 -88
- package/dist/component.default.d.ts +0 -268
- package/dist/custom-client-2V9lmzUf.js +0 -2655
- package/dist/custom-client-HkM1Sdzv.cjs +0 -2726
- package/dist/dual-modes-Cb7ThvoV.cjs +0 -3020
- package/dist/dual-modes-Cy0_W4O2.js +0 -2930
- package/dist/errors-C962uJdS.cjs +0 -220
- package/dist/errors-Cg1G0Awu.js +0 -161
- package/dist/example.d.ts +0 -45
- package/dist/execute-Aw4cbIx-.js +0 -1080
- package/dist/execute-COIHOIKR.cjs +0 -1081
- 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/jsx-B0iYyvfr.js +0 -100
- package/dist/jsx-D5Y2cPo-.cjs +0 -129
- package/dist/jsx.d.ts +0 -11
- package/dist/message-stream/index.d.ts +0 -9
- package/dist/message-stream/instructions.d.ts +0 -22
- package/dist/message-stream/normalizer.d.ts +0 -21
- package/dist/message-stream/parser.d.ts +0 -83
- package/dist/message-stream/registry.d.ts +0 -14
- package/dist/message-stream/replayable.d.ts +0 -27
- 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 -96
- package/dist/message-stream/validator.d.ts +0 -23
- 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/common.d.ts +0 -6
- 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.d.ts +0 -18
- 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/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/stream.test.d.ts → result.test.d.ts} +0 -0
- /package/dist/{message-stream/validator.test.d.ts → runtime/chat-delivery.test.d.ts} +0 -0
- /package/dist/{prompts/common.test.d.ts → runtime/citations.test.d.ts} +0 -0
- /package/dist/{prompts/protocol.test.d.ts → runtime/compatibility-regressions.test.d.ts} +0 -0
- /package/dist/runtime/{interpret-result.test.d.ts → context-registration.test.d.ts} +0 -0
- /package/dist/{transcript.test.d.ts → runtime/error-recovery.test.d.ts} +0 -0
- /package/dist/{truncator.test.d.ts → runtime/errors.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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
export { renderMessageDeliveries } from './execution-activity.js';
|
|
6
|
+
export type ExecutionOutcome = {
|
|
7
|
+
type: 'inspect';
|
|
8
|
+
value: unknown;
|
|
9
|
+
available: boolean;
|
|
10
|
+
explicit: boolean;
|
|
11
|
+
} | {
|
|
12
|
+
type: 'exit';
|
|
13
|
+
name: string;
|
|
14
|
+
value: unknown;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'error';
|
|
17
|
+
message: string;
|
|
18
|
+
error?: unknown;
|
|
19
|
+
exitName?: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'cancelled';
|
|
22
|
+
message: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'interrupted';
|
|
25
|
+
reason: 'stream' | 'thinking';
|
|
26
|
+
message?: string;
|
|
27
|
+
context?: unknown;
|
|
28
|
+
stacktrace?: string;
|
|
29
|
+
};
|
|
30
|
+
export type ExecutionReport = {
|
|
31
|
+
outcome: ExecutionOutcome;
|
|
32
|
+
activity: ExecutionActivity;
|
|
33
|
+
memory: MemoryReport;
|
|
34
|
+
source?: {
|
|
35
|
+
requested?: string;
|
|
36
|
+
executed?: string;
|
|
37
|
+
};
|
|
38
|
+
requiresExit?: boolean;
|
|
39
|
+
iteration?: number;
|
|
40
|
+
identity?: InspectionIdentity;
|
|
41
|
+
inspector?: Inspector;
|
|
42
|
+
maxTokens?: number;
|
|
43
|
+
policies?: InspectionPolicyLookup;
|
|
44
|
+
};
|
|
45
|
+
/** Format one settled outcome; execution is responsible for deciding what happened. */
|
|
46
|
+
export declare function renderExecutionReport({ outcome, activity, memory, source, requiresExit, iteration, identity, inspector, maxTokens, policies, }: ExecutionReport): string;
|
|
47
|
+
/** Keep the requested assistant call intact while disclosing the source the host actually ran. */
|
|
48
|
+
export declare function renderExecutionOverride(executedCode?: string, requestedCode?: string, inspector?: Inspector, identity?: InspectionIdentity): string | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,19 @@
|
|
|
1
|
+
import { CitationsManager } from '../../chat/citations.js';
|
|
2
|
+
export type SearchChallenge = {
|
|
3
|
+
id: string;
|
|
4
|
+
size: number;
|
|
5
|
+
profile: 'scope' | 'revision' | 'join' | 'arithmetic';
|
|
6
|
+
language: string;
|
|
7
|
+
position: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const longSearchChallenges: SearchChallenge[];
|
|
10
|
+
/** Synthetic VDK-shaped search results. No customer data or external search is involved. */
|
|
11
|
+
export declare function buildSearchChallenge(challenge: SearchChallenge, compact: boolean, citations: CitationsManager): {
|
|
12
|
+
question: string;
|
|
13
|
+
facts: string[];
|
|
14
|
+
expectedSources: string[];
|
|
15
|
+
relevantSources: string[];
|
|
16
|
+
evidenceTags: string[];
|
|
17
|
+
content: string;
|
|
18
|
+
reason: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** Synthetic multilingual inputs for native protocol boundary tests. */
|
|
2
|
+
export declare const protocolLanguages: readonly [{
|
|
3
|
+
readonly language: 'English';
|
|
4
|
+
readonly hello: 'Hello!';
|
|
5
|
+
readonly question: 'Help me choose a plan.';
|
|
6
|
+
readonly reply: 'How many conversations do you expect per month?';
|
|
7
|
+
readonly checking: 'Checking.';
|
|
8
|
+
}, {
|
|
9
|
+
readonly language: 'French';
|
|
10
|
+
readonly hello: 'Bonjour !';
|
|
11
|
+
readonly question: 'Aidez-moi à choisir un forfait.';
|
|
12
|
+
readonly reply: 'Combien de conversations prévoyez-vous par mois ?';
|
|
13
|
+
readonly checking: 'Je vérifie.';
|
|
14
|
+
}, {
|
|
15
|
+
readonly language: 'Spanish';
|
|
16
|
+
readonly hello: '¡Hola!';
|
|
17
|
+
readonly question: 'Ayúdame a elegir un plan.';
|
|
18
|
+
readonly reply: '¿Cuántas conversaciones esperas al mes?';
|
|
19
|
+
readonly checking: 'Estoy comprobando.';
|
|
20
|
+
}, {
|
|
21
|
+
readonly language: 'German';
|
|
22
|
+
readonly hello: 'Hallo!';
|
|
23
|
+
readonly question: 'Hilf mir, einen Tarif auszuwählen.';
|
|
24
|
+
readonly reply: 'Wie viele Gespräche erwartest du pro Monat?';
|
|
25
|
+
readonly checking: 'Ich prüfe das.';
|
|
26
|
+
}, {
|
|
27
|
+
readonly language: 'Portuguese';
|
|
28
|
+
readonly hello: 'Olá!';
|
|
29
|
+
readonly question: 'Ajude-me a escolher um plano.';
|
|
30
|
+
readonly reply: 'Quantas conversas você espera por mês?';
|
|
31
|
+
readonly checking: 'Estou verificando.';
|
|
32
|
+
}, {
|
|
33
|
+
readonly language: 'Italian';
|
|
34
|
+
readonly hello: 'Ciao!';
|
|
35
|
+
readonly question: 'Aiutami a scegliere un piano.';
|
|
36
|
+
readonly reply: 'Quante conversazioni prevedi al mese?';
|
|
37
|
+
readonly checking: 'Sto controllando.';
|
|
38
|
+
}, {
|
|
39
|
+
readonly language: 'Arabic';
|
|
40
|
+
readonly hello: 'مرحباً!';
|
|
41
|
+
readonly question: 'ساعدني في اختيار خطة.';
|
|
42
|
+
readonly reply: 'كم محادثة تتوقع في الشهر؟';
|
|
43
|
+
readonly checking: 'أتحقق الآن.';
|
|
44
|
+
}, {
|
|
45
|
+
readonly language: 'Chinese';
|
|
46
|
+
readonly hello: '你好!';
|
|
47
|
+
readonly question: '帮我选择一个套餐。';
|
|
48
|
+
readonly reply: '你预计每月有多少次对话?';
|
|
49
|
+
readonly checking: '正在查询。';
|
|
50
|
+
}, {
|
|
51
|
+
readonly language: 'Japanese';
|
|
52
|
+
readonly hello: 'こんにちは!';
|
|
53
|
+
readonly question: 'プラン選びを手伝ってください。';
|
|
54
|
+
readonly reply: '月に何件の会話を想定していますか?';
|
|
55
|
+
readonly checking: '確認しています。';
|
|
56
|
+
}, {
|
|
57
|
+
readonly language: 'Korean';
|
|
58
|
+
readonly hello: '안녕하세요!';
|
|
59
|
+
readonly question: '요금제 선택을 도와주세요.';
|
|
60
|
+
readonly reply: '월별 대화 수는 얼마나 예상하시나요?';
|
|
61
|
+
readonly checking: '확인 중입니다.';
|
|
62
|
+
}, {
|
|
63
|
+
readonly language: 'Hindi';
|
|
64
|
+
readonly hello: 'नमस्ते!';
|
|
65
|
+
readonly question: 'एक योजना चुनने में मेरी मदद करें।';
|
|
66
|
+
readonly reply: 'आपको हर महीने कितनी बातचीत की उम्मीद है?';
|
|
67
|
+
readonly checking: 'मैं जाँच कर रहा हूँ।';
|
|
68
|
+
}, {
|
|
69
|
+
readonly language: 'Russian';
|
|
70
|
+
readonly hello: 'Здравствуйте!';
|
|
71
|
+
readonly question: 'Помогите мне выбрать тариф.';
|
|
72
|
+
readonly reply: 'Сколько разговоров вы ожидаете в месяц?';
|
|
73
|
+
readonly checking: 'Проверяю.';
|
|
74
|
+
}];
|
|
@@ -1,35 +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 completed `■send` block. On streaming clients this fires
|
|
13
|
-
* while the model is still generating — messages are delivered progressively.
|
|
14
|
-
*/
|
|
15
|
-
onSend?: (send: ParsedSend, metadata: MessageMetadata) => Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Called for each `■send` body chunk as it is parsed from the stream
|
|
18
|
-
* (streaming clients only), or with a restart delta before replacement output.
|
|
19
|
-
* Text errors are best-effort; restart errors terminate generation.
|
|
20
|
-
*/
|
|
21
26
|
onSendDelta?: (delta: MessageDelta) => Promise<void> | void;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*/
|
|
26
|
-
onRunStart?: () => void;
|
|
27
|
-
/**
|
|
28
|
-
* Called with the code of the first `■run` block the moment it is fully
|
|
29
|
-
* parsed — the rest of the response (e.g. `■next`) may still be streaming
|
|
30
|
-
* (streaming clients only). Used to start executing the code early.
|
|
31
|
-
*/
|
|
32
|
-
onRunComplete?: (code: string) => void;
|
|
27
|
+
onBeforeRequest?: ExecutionHooks['onBeforeRequest'];
|
|
28
|
+
/** Start a complete normalized call without waiting for execution or the stream tail. */
|
|
29
|
+
onToolCalls?: (calls: CognitiveToolCall[]) => boolean;
|
|
33
30
|
};
|
|
34
|
-
export declare
|
|
35
|
-
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,59 @@
|
|
|
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
|
+
/** A child message keeps its identity from preparation through acknowledged delivery. */
|
|
6
|
+
export type PreparedMessage = {
|
|
7
|
+
id: string;
|
|
8
|
+
component: RenderedComponent;
|
|
9
|
+
};
|
|
10
|
+
export type JavaScriptOutcome = {
|
|
11
|
+
type: 'inspect';
|
|
12
|
+
value: unknown;
|
|
13
|
+
} | {
|
|
14
|
+
type: 'exit';
|
|
15
|
+
exit: Exit;
|
|
16
|
+
value: unknown;
|
|
17
|
+
};
|
|
18
|
+
type DecisionReceipt = Readonly<{
|
|
19
|
+
__llmz_decision: string;
|
|
20
|
+
}>;
|
|
21
|
+
type TerminalOutcome = Extract<JavaScriptOutcome, {
|
|
22
|
+
type: 'exit';
|
|
23
|
+
}>;
|
|
24
|
+
export type JavaScriptBindings = {
|
|
25
|
+
exit(name?: string, value?: unknown): never;
|
|
26
|
+
inspect(value: unknown): DecisionReceipt;
|
|
27
|
+
chat: Readonly<Record<string, (input: unknown) => void>>;
|
|
28
|
+
};
|
|
29
|
+
export type JavaScriptApi = {
|
|
30
|
+
bindings: JavaScriptBindings;
|
|
31
|
+
resolve(value: unknown): JavaScriptOutcome | undefined;
|
|
32
|
+
isReceipt(value: unknown): boolean;
|
|
33
|
+
getTerminalOutcome(): TerminalOutcome | undefined;
|
|
34
|
+
/** The first host interruption closes execution before guest handlers can consume it. */
|
|
35
|
+
getInterruption(): ThinkSignal | undefined;
|
|
36
|
+
throwIfTerminated(): void;
|
|
37
|
+
track<T>(operation: () => Promise<T>): Promise<T>;
|
|
38
|
+
assertOpen(): void;
|
|
39
|
+
/** Record validation failures and close host operations on critical configuration errors. */
|
|
40
|
+
reportError(error: unknown): void;
|
|
41
|
+
/** Called at program settlement, before background work can invoke another host operation. */
|
|
42
|
+
complete(): void;
|
|
43
|
+
/** Joins automatic message delivery and business work before the iteration can settle. */
|
|
44
|
+
close(): Promise<void>;
|
|
45
|
+
};
|
|
46
|
+
type JavaScriptApiOptions = {
|
|
47
|
+
iteration: Pick<Iteration, 'id' | 'nativeCallId'>;
|
|
48
|
+
components: ComponentRegistry;
|
|
49
|
+
exits: readonly Exit[];
|
|
50
|
+
deliver(messages: readonly PreparedMessage[]): Promise<void>;
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
onError?(error: unknown): void;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Component methods send synchronously; the runtime joins delivery in close().
|
|
56
|
+
* Inspection returns a decision, while exit latches an outcome and stops the program.
|
|
57
|
+
*/
|
|
58
|
+
export declare function createJavaScriptApi({ iteration, components, exits, deliver, signal, onError, }: JavaScriptApiOptions): JavaScriptApi;
|
|
59
|
+
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,16 @@
|
|
|
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';
|
|
5
4
|
import { ExecutionHooks } from './types.js';
|
|
6
5
|
type ToolWrapperProps = {
|
|
7
|
-
chat?: Chat;
|
|
8
6
|
tool: Tool;
|
|
9
7
|
object?: string;
|
|
10
|
-
traces: Trace[];
|
|
11
8
|
iteration: Iteration;
|
|
12
9
|
beforeHook?: ExecutionHooks['onBeforeTool'];
|
|
13
10
|
afterHook?: ExecutionHooks['onAfterTool'];
|
|
11
|
+
onTruncation?: (value: unknown, policy: TruncationPolicy) => void;
|
|
12
|
+
onResult?: (value: unknown) => void;
|
|
14
13
|
controller: AbortController;
|
|
15
14
|
};
|
|
16
|
-
export declare function wrapTool({
|
|
15
|
+
export declare function wrapTool({ tool, object, iteration, beforeHook, afterHook, onTruncation, onResult, controller, }: ToolWrapperProps): (input: any) => Promise<any>;
|
|
17
16
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|