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
package/dist/context.d.ts
CHANGED
|
@@ -1,39 +1,35 @@
|
|
|
1
1
|
import { Models, SttModels } from '@botpress/cognitive';
|
|
2
2
|
import { z } from '@bpinternal/zui';
|
|
3
|
-
import { Chat } from './chat.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import type
|
|
3
|
+
import { Chat } from './chat/chat.js';
|
|
4
|
+
import { type ComponentRegistry } from './chat/component.js';
|
|
5
|
+
import { type ResolvedResponse } from './chat/response.js';
|
|
6
|
+
import { type ErrorDetails, type LLMzFailure } from './errors.js';
|
|
7
7
|
import { Exit } from './exit.js';
|
|
8
8
|
import { ValueOrGetter } from './getter.js';
|
|
9
|
-
import {
|
|
10
|
-
import type { Diagnostic } from './message-stream/types.js';
|
|
9
|
+
import { type Inspector, type OnInspect } from './inspection.js';
|
|
11
10
|
import { ObjectInstance } from './objects.js';
|
|
12
|
-
import { LLMzPrompts
|
|
13
|
-
import {
|
|
11
|
+
import { LLMzPrompts } from './prompts/prompt.js';
|
|
12
|
+
import { Session } from './session/session.js';
|
|
14
13
|
import { Tool } from './tool.js';
|
|
15
|
-
import { Transcript, TranscriptArray } from './transcript.js';
|
|
16
14
|
import { ObjectMutation, Serializable, Trace } from './types.js';
|
|
17
15
|
/**
|
|
18
|
-
* Tokenizer
|
|
19
|
-
*
|
|
16
|
+
* Tokenizer estimate of the final request after compaction, grouped by purpose.
|
|
17
|
+
* Categories sum to the measured request size; provider-reported usage is separate.
|
|
18
|
+
* Media transport URLs and encoded bytes are excluded; media token usage is
|
|
19
|
+
* provider-specific and is not available until the provider reports usage.
|
|
20
20
|
*/
|
|
21
21
|
export type ContextTokens = {
|
|
22
|
-
/** Total measured size
|
|
22
|
+
/** Total measured request size (sum of all the parts below). */
|
|
23
23
|
total: number;
|
|
24
|
-
/**
|
|
24
|
+
/** System scaffolding and structured-message overhead not attributed below. */
|
|
25
25
|
framework: number;
|
|
26
26
|
/** The identity / instructions section. */
|
|
27
27
|
instructions: number;
|
|
28
|
-
/**
|
|
28
|
+
/** Callable JavaScript declarations and native tool schemas. */
|
|
29
29
|
tools: number;
|
|
30
|
-
/**
|
|
31
|
-
transcript: number;
|
|
32
|
-
/** The ■ protocol reference documenting components and exits. */
|
|
30
|
+
/** Native execution rules documenting components and exits. */
|
|
33
31
|
protocol: number;
|
|
34
|
-
/**
|
|
35
|
-
examples: number;
|
|
36
|
-
/** Messages carried over from previous iterations (assistant responses, execution results, errors). */
|
|
32
|
+
/** Current input, retained native history, tool results, and the memory overview. */
|
|
37
33
|
iterations: number;
|
|
38
34
|
};
|
|
39
35
|
/** Token usage of a single iteration's LLM call. */
|
|
@@ -46,27 +42,27 @@ export type TokenUsage = {
|
|
|
46
42
|
total: number;
|
|
47
43
|
/**
|
|
48
44
|
* The effective context window limit of this call, in tokens:
|
|
49
|
-
* `min(options.maxTokens, model
|
|
45
|
+
* `min(options.maxTokens, smallest configured model input limit)`. Use it to compute the
|
|
50
46
|
* percentage of context used (e.g. `context.total / limit`).
|
|
51
47
|
* Undefined until the LLM call starts.
|
|
52
48
|
*/
|
|
53
49
|
limit?: number;
|
|
54
|
-
/** Measured context size by part of the
|
|
50
|
+
/** Measured context size by part of the request after compaction. */
|
|
55
51
|
context: ContextTokens;
|
|
56
52
|
};
|
|
57
53
|
export type IterationParameters = {
|
|
58
|
-
|
|
54
|
+
chatEnabled: boolean;
|
|
59
55
|
tools: Tool[];
|
|
60
56
|
objects: ObjectInstance[];
|
|
61
57
|
exits: Exit[];
|
|
62
58
|
instructions?: string;
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
components: ComponentRegistry;
|
|
60
|
+
response?: ResolvedResponse;
|
|
65
61
|
model: Models | Models[];
|
|
66
62
|
temperature: number;
|
|
67
63
|
reasoningEffort?: 'low' | 'medium' | 'high' | 'dynamic' | 'none';
|
|
68
64
|
};
|
|
69
|
-
export type IterationStatus = IterationStatuses.Pending | IterationStatuses.GenerationError | IterationStatuses.ExecutionError | IterationStatuses.InvalidCodeError | IterationStatuses.Thinking | IterationStatuses.
|
|
65
|
+
export type IterationStatus = IterationStatuses.Pending | IterationStatuses.GenerationError | IterationStatuses.ExecutionError | IterationStatuses.InvalidCodeError | IterationStatuses.Thinking | IterationStatuses.ExitSuccess | IterationStatuses.ExitError | IterationStatuses.Aborted;
|
|
70
66
|
export declare namespace IterationStatuses {
|
|
71
67
|
type Pending = {
|
|
72
68
|
type: 'pending';
|
|
@@ -97,16 +93,10 @@ export declare namespace IterationStatuses {
|
|
|
97
93
|
/** The value returned by the executed code (or the context provided by a ThinkSignal). */
|
|
98
94
|
variables: unknown;
|
|
99
95
|
metadata?: Record<string, unknown>;
|
|
100
|
-
/** A
|
|
96
|
+
/** A legacy VM control-flow signal paused execution. Tool ThinkSignals now use forced inspection. */
|
|
101
97
|
interrupted?: boolean;
|
|
102
98
|
};
|
|
103
99
|
};
|
|
104
|
-
type Callback = {
|
|
105
|
-
type: 'callback_requested';
|
|
106
|
-
callback_requested: {
|
|
107
|
-
signal: SnapshotSignal;
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
100
|
type ExitSuccess<T = unknown> = {
|
|
111
101
|
type: 'exit_success';
|
|
112
102
|
exit_success: {
|
|
@@ -130,218 +120,14 @@ export declare namespace IterationStatuses {
|
|
|
130
120
|
};
|
|
131
121
|
}
|
|
132
122
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* The ThinkExit allows agents to pause execution and reflect on the current situation,
|
|
136
|
-
* variables, and context before continuing. There are two ways to trigger thinking:
|
|
137
|
-
*
|
|
138
|
-
* 1. **Agent-initiated**: Agent calls `return { action: 'think' }` to pause and reflect
|
|
139
|
-
* 2. **Tool/Hook-initiated**: Tools or hooks throw `ThinkSignal` to force agent reflection
|
|
140
|
-
*
|
|
141
|
-
* This exit is automatically available in all LLMz executions and is commonly used for:
|
|
142
|
-
* - Complex decision making that requires analysis
|
|
143
|
-
* - Debugging and understanding current variable state
|
|
144
|
-
* - Planning multi-step operations
|
|
145
|
-
* - Tool feedback and result processing
|
|
146
|
-
* - Reflecting on previous iterations and results
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* ```typescript
|
|
150
|
-
* // Agent retrieves web search results and decides to think about them
|
|
151
|
-
* const results = await searchWeb(query)
|
|
152
|
-
*
|
|
153
|
-
* // Agent decides it needs to think (look at the search results) before responding
|
|
154
|
-
* return { action: 'think', results }
|
|
155
|
-
* ```
|
|
156
|
-
*
|
|
157
|
-
* Sometimes, as the author of the tool, you may want to always force the agent to think about the results.
|
|
158
|
-
* In this case, you can throw a `ThinkSignal` from the tool handler to trigger thinking.
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* ```typescript
|
|
162
|
-
* // Tool-initiated thinking using ThinkSignal
|
|
163
|
-
* import { ThinkSignal } from 'llmz'
|
|
164
|
-
*
|
|
165
|
-
* const searchTool = new Tool({
|
|
166
|
-
* name: 'search',
|
|
167
|
-
* handler: async ({ query }) => {
|
|
168
|
-
* const results = await performSearch(query)
|
|
169
|
-
*
|
|
170
|
-
* if (!results.length) {
|
|
171
|
-
* // Force agent to think about alternative approaches
|
|
172
|
-
* throw new ThinkSignal(
|
|
173
|
-
* 'No search results found',
|
|
174
|
-
* 'No results were found. Consider rephrasing the query or using a different approach.'
|
|
175
|
-
* )
|
|
176
|
-
* }
|
|
177
|
-
*
|
|
178
|
-
* // Provide context for agent to process results
|
|
179
|
-
* throw new ThinkSignal(
|
|
180
|
-
* 'Search completed with results',
|
|
181
|
-
* `Found ${results.length} results. Process them carefully and provide citations.`
|
|
182
|
-
* )
|
|
183
|
-
* }
|
|
184
|
-
* })
|
|
185
|
-
* ```
|
|
186
|
-
* When an iteration ends with ThinkExit, the agent will automatically loop and start a new iteration to continue processing, unless iteration limit is reached.
|
|
187
|
-
*
|
|
188
|
-
* The thinking process helps agents:
|
|
189
|
-
* - Avoid rushing into incorrect solutions
|
|
190
|
-
* - Better understand complex problems and tool results
|
|
191
|
-
* - Maintain variable state across iterations
|
|
192
|
-
* - Process feedback from tools and hooks
|
|
193
|
-
* - Provide more thoughtful and accurate responses
|
|
194
|
-
*/
|
|
195
|
-
export declare const ThinkExit: Exit<unknown>;
|
|
196
|
-
/**
|
|
197
|
-
* Built-in exit for waiting for user input in chat mode.
|
|
198
|
-
*
|
|
199
|
-
* The ListenExit is automatically available when chat mode is enabled (when a Chat
|
|
200
|
-
* instance is provided to execute()). When an agent calls `return { action: 'listen' }`,
|
|
201
|
-
* the execution pauses and waits for user input before continuing the conversation.
|
|
202
|
-
*
|
|
203
|
-
* This exit is essential for interactive conversational agents and is used to:
|
|
204
|
-
* - Wait for user responses in chat interfaces
|
|
205
|
-
* - Pause execution until user provides input
|
|
206
|
-
* - Enable back-and-forth conversation flow
|
|
207
|
-
* - Allow users to guide the conversation direction
|
|
208
|
-
*
|
|
209
|
-
* The ListenExit is only available in chat mode - it will not be present in
|
|
210
|
-
* worker mode executions where no chat interface is provided.
|
|
211
|
-
*
|
|
212
|
-
* @example
|
|
213
|
-
* ```typescript
|
|
214
|
-
* // Agent generated code using ListenExit in chat mode
|
|
215
|
-
* yield <Message>What would you like me to help you with today?</Message>
|
|
216
|
-
* yield <Button action="postback" label="Get Weather" value="weather" />
|
|
217
|
-
* yield <Button action="postback" label="Set Reminder" value="reminder" />
|
|
218
|
-
*
|
|
219
|
-
* // Wait for user to respond
|
|
220
|
-
* return { action: 'listen' }
|
|
221
|
-
* ```
|
|
222
|
-
*
|
|
223
|
-
* @example
|
|
224
|
-
* ```typescript
|
|
225
|
-
* // Standard chat interaction pattern
|
|
226
|
-
* const calculation = 2 + 8
|
|
227
|
-
* yield <Message>The result of `2 + 8` is **{calculation}**.</Message>
|
|
228
|
-
* return { action: 'listen' }
|
|
229
|
-
* ```
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* ```typescript
|
|
233
|
-
* // CLI chat example with ListenExit handling
|
|
234
|
-
* const chat = new CLIChat()
|
|
235
|
-
*
|
|
236
|
-
* while (chat.iterate()) {
|
|
237
|
-
* const result = await execute({
|
|
238
|
-
* instructions: 'Help the user with their questions',
|
|
239
|
-
* chat,
|
|
240
|
-
* client,
|
|
241
|
-
* })
|
|
242
|
-
*
|
|
243
|
-
* if (result.is(ListenExit)) {
|
|
244
|
-
* // CLIChat handles prompting user automatically
|
|
245
|
-
* continue
|
|
246
|
-
* } else {
|
|
247
|
-
* console.log('Conversation ended')
|
|
248
|
-
* break
|
|
249
|
-
* }
|
|
250
|
-
* }
|
|
251
|
-
* ```
|
|
252
|
-
*
|
|
253
|
-
* The ListenExit enables natural conversation flow where:
|
|
254
|
-
* - Agent sends messages and waits for responses
|
|
255
|
-
* - User provides input to guide the conversation
|
|
256
|
-
* - Conversation continues iteratively until completion
|
|
257
|
-
* - Chat interface manages the input/output cycle
|
|
123
|
+
* Chat completion. JavaScript uses `return exit('listen')`
|
|
124
|
+
* to wait for user input. A plain assistant answer also implies this exit.
|
|
258
125
|
*/
|
|
259
126
|
export declare const ListenExit: Exit<unknown>;
|
|
260
127
|
/**
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
* It provides a standard way to complete execution with either success or failure outcomes.
|
|
265
|
-
* The exit uses a discriminated union schema to ensure type-safe handling of both success
|
|
266
|
-
* and error cases.
|
|
267
|
-
*
|
|
268
|
-
* This exit is commonly used for:
|
|
269
|
-
* - Simple worker mode executions without custom completion logic
|
|
270
|
-
* - Standardized success/failure reporting
|
|
271
|
-
* - Basic task completion with result or error information
|
|
272
|
-
* - Default fallback when no specific exit behavior is needed
|
|
273
|
-
*
|
|
274
|
-
* @example
|
|
275
|
-
* ```typescript
|
|
276
|
-
* // Agent generated code using DefaultExit for successful completion
|
|
277
|
-
* const data = await fetchUserData(userId)
|
|
278
|
-
* const processedResult = processData(data)
|
|
279
|
-
*
|
|
280
|
-
* return {
|
|
281
|
-
* action: 'done',
|
|
282
|
-
* success: true,
|
|
283
|
-
* result: processedResult
|
|
284
|
-
* }
|
|
285
|
-
* ```
|
|
286
|
-
*
|
|
287
|
-
* @example
|
|
288
|
-
* ```typescript
|
|
289
|
-
* // Agent generated code using DefaultExit for error cases
|
|
290
|
-
* try {
|
|
291
|
-
* const result = await riskyOperation()
|
|
292
|
-
* return { action: 'done', success: true, result }
|
|
293
|
-
* } catch (error) {
|
|
294
|
-
* return {
|
|
295
|
-
* action: 'done',
|
|
296
|
-
* success: false,
|
|
297
|
-
* error: `Operation failed: ${error.message}`
|
|
298
|
-
* }
|
|
299
|
-
* }
|
|
300
|
-
* ```
|
|
301
|
-
*
|
|
302
|
-
* @example
|
|
303
|
-
* ```typescript
|
|
304
|
-
* import { execute, DefaultExit } from 'llmz'
|
|
305
|
-
*
|
|
306
|
-
* // Handling DefaultExit in execution results
|
|
307
|
-
* const result = await execute({
|
|
308
|
-
* instructions: 'Process the user data and return results',
|
|
309
|
-
* // No custom exits provided - DefaultExit will be used
|
|
310
|
-
* client,
|
|
311
|
-
* })
|
|
312
|
-
*
|
|
313
|
-
* if (result.is(DefaultExit)) {
|
|
314
|
-
* if (result.output.success) {
|
|
315
|
-
* console.log('Success:', result.output.result)
|
|
316
|
-
* } else {
|
|
317
|
-
* console.error('Error:', result.output.error)
|
|
318
|
-
* }
|
|
319
|
-
* }
|
|
320
|
-
* ```
|
|
321
|
-
*
|
|
322
|
-
* @example
|
|
323
|
-
* ```typescript
|
|
324
|
-
* // Worker mode execution with automatic DefaultExit
|
|
325
|
-
* const result = await execute({
|
|
326
|
-
* instructions: 'Calculate fibonacci numbers up to 100',
|
|
327
|
-
* tools: [mathTools],
|
|
328
|
-
* client,
|
|
329
|
-
* // No chat provided = worker mode
|
|
330
|
-
* // No exits provided = DefaultExit automatically added
|
|
331
|
-
* })
|
|
332
|
-
*
|
|
333
|
-
* // Result will use DefaultExit for completion
|
|
334
|
-
* if (result.isSuccess() && result.is(DefaultExit)) {
|
|
335
|
-
* const { success, result: data, error } = result.output
|
|
336
|
-
* // Handle success/failure cases
|
|
337
|
-
* }
|
|
338
|
-
* ```
|
|
339
|
-
*
|
|
340
|
-
* The DefaultExit provides a consistent interface for:
|
|
341
|
-
* - Type-safe success/failure handling
|
|
342
|
-
* - Standardized result reporting across different executions
|
|
343
|
-
* - Automatic fallback behavior when no custom exits are defined
|
|
344
|
-
* - Clear separation between successful results and error conditions
|
|
128
|
+
* Worker completion when exits are omitted. JavaScript returns
|
|
129
|
+
* `exit('done', { success: true, result })` or
|
|
130
|
+
* `exit('done', { success: false, error })`.
|
|
345
131
|
*/
|
|
346
132
|
export declare const DefaultExit: Exit<{
|
|
347
133
|
success: true;
|
|
@@ -353,13 +139,11 @@ export declare const DefaultExit: Exit<{
|
|
|
353
139
|
export declare namespace Iteration {
|
|
354
140
|
type JSON = {
|
|
355
141
|
id: string;
|
|
356
|
-
messages: LLMzPrompts.Message[];
|
|
357
142
|
code?: string;
|
|
358
143
|
traces: Trace[];
|
|
359
144
|
model: Models | Models[];
|
|
360
145
|
temperature: number;
|
|
361
146
|
reasoningEffort?: 'low' | 'medium' | 'high' | 'dynamic' | 'none';
|
|
362
|
-
variables: Record<string, any>;
|
|
363
147
|
started_ts: number;
|
|
364
148
|
ended_ts?: number;
|
|
365
149
|
status: IterationStatus;
|
|
@@ -372,32 +156,35 @@ export declare namespace Iteration {
|
|
|
372
156
|
tokens: number;
|
|
373
157
|
spend: number;
|
|
374
158
|
output: string;
|
|
375
|
-
diagnostics?: Diagnostic[];
|
|
376
159
|
model: string;
|
|
377
160
|
time_to_first_token?: number;
|
|
378
161
|
time_to_last_token?: number;
|
|
379
162
|
};
|
|
380
163
|
tokens?: TokenUsage;
|
|
381
|
-
transcript: Transcript.Message[];
|
|
382
|
-
tools: Tool.JSON[];
|
|
383
|
-
objects: ObjectInstance.JSON[];
|
|
384
|
-
exits: Exit.JSON[];
|
|
385
|
-
instructions?: string;
|
|
386
164
|
duration?: string;
|
|
387
165
|
error?: string | null;
|
|
166
|
+
exception?: ErrorDetails;
|
|
167
|
+
errors: ErrorDetails[];
|
|
388
168
|
isChatEnabled?: boolean;
|
|
389
169
|
};
|
|
390
170
|
}
|
|
391
171
|
export declare class Iteration implements Serializable<Iteration.JSON> {
|
|
392
172
|
id: string;
|
|
393
|
-
|
|
173
|
+
readonly systemMessage: LLMzPrompts.Message;
|
|
394
174
|
code?: string;
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
175
|
+
sessionInfo?: {
|
|
176
|
+
id: string;
|
|
177
|
+
number: number;
|
|
178
|
+
turn: number;
|
|
179
|
+
turnId: string;
|
|
180
|
+
timestamp: number;
|
|
181
|
+
};
|
|
182
|
+
/** Outer native call that owns the current JavaScript execution. */
|
|
183
|
+
nativeCallId?: string;
|
|
184
|
+
traces: Trace[];
|
|
185
|
+
private readonly _onTrace?;
|
|
186
|
+
/** Record a runtime trace and notify the observer without changing execution on observer errors. */
|
|
187
|
+
recordTrace: (trace: Trace) => void;
|
|
401
188
|
/**
|
|
402
189
|
* Token usage of this iteration's LLM call. The `context` breakdown is measured
|
|
403
190
|
* when the prompt is assembled; `input`/`output` are filled in once the LLM call
|
|
@@ -407,12 +194,17 @@ export declare class Iteration implements Serializable<Iteration.JSON> {
|
|
|
407
194
|
started_ts: number;
|
|
408
195
|
ended_ts?: number;
|
|
409
196
|
status: IterationStatus;
|
|
197
|
+
/** Original failure for programmatic handling. Execution errors retain their typed cause. */
|
|
198
|
+
exception?: LLMzFailure;
|
|
199
|
+
/** All observed failures, including tool errors caught by generated code. */
|
|
200
|
+
readonly errors: LLMzFailure[];
|
|
201
|
+
recordError(value: unknown): LLMzFailure;
|
|
410
202
|
private _mutations;
|
|
411
203
|
get mutations(): ObjectMutation[];
|
|
412
204
|
trackMutation(mutation: ObjectMutation): void;
|
|
413
205
|
private _parameters;
|
|
414
|
-
get components():
|
|
415
|
-
get
|
|
206
|
+
get components(): ComponentRegistry;
|
|
207
|
+
get response(): ResolvedResponse | undefined;
|
|
416
208
|
get tools(): Tool<z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any>>[];
|
|
417
209
|
get objects(): ObjectInstance[];
|
|
418
210
|
get model(): Models | Models[];
|
|
@@ -429,8 +221,6 @@ export declare class Iteration implements Serializable<Iteration.JSON> {
|
|
|
429
221
|
tokens: number;
|
|
430
222
|
spend: number;
|
|
431
223
|
output: string;
|
|
432
|
-
/** Syntax diagnostics from the response parser; raw output remains available above. */
|
|
433
|
-
diagnostics?: Diagnostic[];
|
|
434
224
|
model: string;
|
|
435
225
|
/** Milliseconds between the LLM call start and the first streamed token. Only set on streaming clients. */
|
|
436
226
|
time_to_first_token?: number;
|
|
@@ -450,30 +240,29 @@ export declare class Iteration implements Serializable<Iteration.JSON> {
|
|
|
450
240
|
status: IterationStatuses.ExitSuccess<R>;
|
|
451
241
|
} & this;
|
|
452
242
|
isSuccessful(this: this): this is this & {
|
|
453
|
-
status: IterationStatuses.ExitSuccess | IterationStatuses.
|
|
243
|
+
status: IterationStatuses.ExitSuccess | IterationStatuses.Thinking;
|
|
454
244
|
};
|
|
455
245
|
isFailed(this: this): this is this & {
|
|
456
246
|
status: IterationStatuses.GenerationError | IterationStatuses.ExecutionError | IterationStatuses.InvalidCodeError | IterationStatuses.ExitError | IterationStatuses.Aborted;
|
|
457
247
|
};
|
|
458
248
|
get duration(): string;
|
|
249
|
+
/** Human-readable failure summary. Use exception for instanceof checks and structured details. */
|
|
459
250
|
get error(): string | null;
|
|
460
251
|
get isChatEnabled(): boolean;
|
|
461
252
|
constructor(props: {
|
|
462
253
|
id: string;
|
|
463
254
|
parameters: IterationParameters;
|
|
464
|
-
|
|
465
|
-
|
|
255
|
+
systemMessage: LLMzPrompts.Message;
|
|
256
|
+
onTrace?: (trace: Trace) => void;
|
|
466
257
|
});
|
|
467
|
-
end(status: IterationStatus): void;
|
|
258
|
+
end(status: IterationStatus, exception?: unknown): void;
|
|
468
259
|
toJSON(): {
|
|
469
260
|
id: string;
|
|
470
|
-
messages: import("@botpress/cognitive").CognitiveMessage[];
|
|
471
261
|
code: string | undefined;
|
|
472
262
|
model: Models[] | Models;
|
|
473
263
|
temperature: number;
|
|
474
264
|
reasoningEffort: "dynamic" | "high" | "low" | "medium" | "none" | undefined;
|
|
475
265
|
traces: import("./types.js").Traces.Trace[];
|
|
476
|
-
variables: Record<string, any>;
|
|
477
266
|
started_ts: number;
|
|
478
267
|
ended_ts: number | undefined;
|
|
479
268
|
status: IterationStatus;
|
|
@@ -486,8 +275,6 @@ export declare class Iteration implements Serializable<Iteration.JSON> {
|
|
|
486
275
|
tokens: number;
|
|
487
276
|
spend: number;
|
|
488
277
|
output: string;
|
|
489
|
-
/** Syntax diagnostics from the response parser; raw output remains available above. */
|
|
490
|
-
diagnostics?: Diagnostic[];
|
|
491
278
|
model: string;
|
|
492
279
|
/** Milliseconds between the LLM call start and the first streamed token. Only set on streaming clients. */
|
|
493
280
|
time_to_first_token?: number;
|
|
@@ -501,45 +288,10 @@ export declare class Iteration implements Serializable<Iteration.JSON> {
|
|
|
501
288
|
};
|
|
502
289
|
} | undefined;
|
|
503
290
|
tokens: TokenUsage | undefined;
|
|
504
|
-
transcript: Transcript.Message[];
|
|
505
|
-
tools: {
|
|
506
|
-
name: string;
|
|
507
|
-
aliases: string[];
|
|
508
|
-
description: string | undefined;
|
|
509
|
-
metadata: Record<string, unknown>;
|
|
510
|
-
input: import("json-schema").JSONSchema7 | undefined;
|
|
511
|
-
output: import("json-schema").JSONSchema7 | undefined;
|
|
512
|
-
staticInputValues: unknown;
|
|
513
|
-
maxRetries: number;
|
|
514
|
-
}[];
|
|
515
|
-
objects: {
|
|
516
|
-
name: string;
|
|
517
|
-
description: string | undefined;
|
|
518
|
-
properties: import("./objects.js").ObjectProperty[] | undefined;
|
|
519
|
-
tools: {
|
|
520
|
-
name: string;
|
|
521
|
-
aliases: string[];
|
|
522
|
-
description: string | undefined;
|
|
523
|
-
metadata: Record<string, unknown>;
|
|
524
|
-
input: import("json-schema").JSONSchema7 | undefined;
|
|
525
|
-
output: import("json-schema").JSONSchema7 | undefined;
|
|
526
|
-
staticInputValues: unknown;
|
|
527
|
-
maxRetries: number;
|
|
528
|
-
}[];
|
|
529
|
-
metadata: Record<string, unknown> | undefined;
|
|
530
|
-
}[];
|
|
531
|
-
exits: {
|
|
532
|
-
name: string;
|
|
533
|
-
aliases: string[];
|
|
534
|
-
description: string;
|
|
535
|
-
metadata: {
|
|
536
|
-
[x: string]: unknown;
|
|
537
|
-
};
|
|
538
|
-
schema: import("json-schema").JSONSchema7 | undefined;
|
|
539
|
-
}[];
|
|
540
|
-
instructions: string | undefined;
|
|
541
291
|
duration: string;
|
|
542
292
|
error: string | null;
|
|
293
|
+
exception: ErrorDetails | undefined;
|
|
294
|
+
errors: ErrorDetails[];
|
|
543
295
|
isChatEnabled: boolean;
|
|
544
296
|
};
|
|
545
297
|
}
|
|
@@ -551,28 +303,30 @@ export declare namespace Context {
|
|
|
551
303
|
timeout: number;
|
|
552
304
|
loop: number;
|
|
553
305
|
metadata: Record<string, any>;
|
|
554
|
-
|
|
306
|
+
sessionId: string;
|
|
555
307
|
};
|
|
556
308
|
}
|
|
557
309
|
export declare class Context implements Serializable<Context.JSON> {
|
|
558
310
|
id: string;
|
|
559
311
|
chat?: Chat;
|
|
560
312
|
instructions?: ValueOrGetter<string, Context>;
|
|
561
|
-
examples?: ValueOrGetter<Example[], Context>;
|
|
562
313
|
objects?: ValueOrGetter<ObjectInstance[], Context>;
|
|
563
314
|
tools?: ValueOrGetter<Tool[], Context>;
|
|
564
315
|
exits?: ValueOrGetter<Exit[], Context>;
|
|
565
316
|
model?: ValueOrGetter<Models | Models[], Context>;
|
|
566
317
|
temperature: ValueOrGetter<number, Context>;
|
|
567
318
|
reasoningEffort?: ValueOrGetter<'low' | 'medium' | 'high' | 'dynamic' | 'none', Context>;
|
|
568
|
-
|
|
319
|
+
session: Session;
|
|
320
|
+
readonly inspector: Inspector;
|
|
569
321
|
timeout: number;
|
|
570
322
|
loop: number;
|
|
571
323
|
/**
|
|
572
324
|
* Optional cap on the model's context window. The effective limit is
|
|
573
|
-
* `min(maxTokens, model
|
|
325
|
+
* `min(maxTokens, smallest configured model input limit)`.
|
|
574
326
|
*/
|
|
575
327
|
maxTokens?: number;
|
|
328
|
+
/** Default display budget; explicitly wrapped tool results can override it. */
|
|
329
|
+
toolResultMaxTokens: number;
|
|
576
330
|
/**
|
|
577
331
|
* Maximum time to wait for the first streamed token, in milliseconds,
|
|
578
332
|
* before the cognitive service falls back to the next model/provider.
|
|
@@ -591,12 +345,9 @@ export declare class Context implements Serializable<Context.JSON> {
|
|
|
591
345
|
*/
|
|
592
346
|
transcriptionModel?: SttModels;
|
|
593
347
|
metadata: Record<string, any>;
|
|
594
|
-
snapshot?: Snapshot;
|
|
595
|
-
private _lastMessageWithoutExecutionState?;
|
|
596
348
|
iteration: number;
|
|
597
349
|
iterations: Iteration[];
|
|
598
|
-
nextIteration(): Promise<Iteration>;
|
|
599
|
-
private _getIterationVariables;
|
|
350
|
+
nextIteration(onTrace?: (trace: Trace) => void): Promise<Iteration>;
|
|
600
351
|
/**
|
|
601
352
|
* Measures the token size of each part of the prompt (pre-truncation).
|
|
602
353
|
* The named parts come from the system prompt; everything else in the system
|
|
@@ -610,7 +361,6 @@ export declare class Context implements Serializable<Context.JSON> {
|
|
|
610
361
|
constructor(props: {
|
|
611
362
|
chat?: Chat;
|
|
612
363
|
instructions?: ValueOrGetter<string, Context>;
|
|
613
|
-
examples?: ValueOrGetter<Example[], Context>;
|
|
614
364
|
objects?: ValueOrGetter<ObjectInstance[], Context>;
|
|
615
365
|
tools?: ValueOrGetter<Tool[], Context>;
|
|
616
366
|
exits?: ValueOrGetter<Exit[], Context>;
|
|
@@ -619,9 +369,11 @@ export declare class Context implements Serializable<Context.JSON> {
|
|
|
619
369
|
reasoningEffort?: ValueOrGetter<'low' | 'medium' | 'high' | 'dynamic' | 'none', Context>;
|
|
620
370
|
model?: ValueOrGetter<Models | Models[], Context>;
|
|
621
371
|
metadata?: Record<string, any>;
|
|
622
|
-
|
|
372
|
+
session?: Session;
|
|
373
|
+
onInspect?: OnInspect;
|
|
623
374
|
timeout?: number;
|
|
624
375
|
maxTokens?: number;
|
|
376
|
+
toolResultMaxTokens?: number;
|
|
625
377
|
maxTimeToFirstToken?: number;
|
|
626
378
|
midStreamFallback?: boolean;
|
|
627
379
|
transcriptionModel?: SttModels;
|
|
@@ -630,13 +382,11 @@ export declare class Context implements Serializable<Context.JSON> {
|
|
|
630
382
|
id: string;
|
|
631
383
|
iterations: {
|
|
632
384
|
id: string;
|
|
633
|
-
messages: import("@botpress/cognitive").CognitiveMessage[];
|
|
634
385
|
code: string | undefined;
|
|
635
386
|
model: Models[] | Models;
|
|
636
387
|
temperature: number;
|
|
637
388
|
reasoningEffort: "dynamic" | "high" | "low" | "medium" | "none" | undefined;
|
|
638
389
|
traces: import("./types.js").Traces.Trace[];
|
|
639
|
-
variables: Record<string, any>;
|
|
640
390
|
started_ts: number;
|
|
641
391
|
ended_ts: number | undefined;
|
|
642
392
|
status: IterationStatus;
|
|
@@ -649,8 +399,6 @@ export declare class Context implements Serializable<Context.JSON> {
|
|
|
649
399
|
tokens: number;
|
|
650
400
|
spend: number;
|
|
651
401
|
output: string;
|
|
652
|
-
/** Syntax diagnostics from the response parser; raw output remains available above. */
|
|
653
|
-
diagnostics?: Diagnostic[];
|
|
654
402
|
model: string;
|
|
655
403
|
/** Milliseconds between the LLM call start and the first streamed token. Only set on streaming clients. */
|
|
656
404
|
time_to_first_token?: number;
|
|
@@ -664,71 +412,16 @@ export declare class Context implements Serializable<Context.JSON> {
|
|
|
664
412
|
};
|
|
665
413
|
} | undefined;
|
|
666
414
|
tokens: TokenUsage | undefined;
|
|
667
|
-
transcript: Transcript.Message[];
|
|
668
|
-
tools: {
|
|
669
|
-
name: string;
|
|
670
|
-
aliases: string[];
|
|
671
|
-
description: string | undefined;
|
|
672
|
-
metadata: Record<string, unknown>;
|
|
673
|
-
input: import("json-schema").JSONSchema7 | undefined;
|
|
674
|
-
output: import("json-schema").JSONSchema7 | undefined;
|
|
675
|
-
staticInputValues: unknown;
|
|
676
|
-
maxRetries: number;
|
|
677
|
-
}[];
|
|
678
|
-
objects: {
|
|
679
|
-
name: string;
|
|
680
|
-
description: string | undefined;
|
|
681
|
-
properties: import("./objects.js").ObjectProperty[] | undefined;
|
|
682
|
-
tools: {
|
|
683
|
-
name: string;
|
|
684
|
-
aliases: string[];
|
|
685
|
-
description: string | undefined;
|
|
686
|
-
metadata: Record<string, unknown>;
|
|
687
|
-
input: import("json-schema").JSONSchema7 | undefined;
|
|
688
|
-
output: import("json-schema").JSONSchema7 | undefined;
|
|
689
|
-
staticInputValues: unknown;
|
|
690
|
-
maxRetries: number;
|
|
691
|
-
}[];
|
|
692
|
-
metadata: Record<string, unknown> | undefined;
|
|
693
|
-
}[];
|
|
694
|
-
exits: {
|
|
695
|
-
name: string;
|
|
696
|
-
aliases: string[];
|
|
697
|
-
description: string;
|
|
698
|
-
metadata: {
|
|
699
|
-
[x: string]: unknown;
|
|
700
|
-
};
|
|
701
|
-
schema: import("json-schema").JSONSchema7 | undefined;
|
|
702
|
-
}[];
|
|
703
|
-
instructions: string | undefined;
|
|
704
415
|
duration: string;
|
|
705
416
|
error: string | null;
|
|
417
|
+
exception: ErrorDetails | undefined;
|
|
418
|
+
errors: ErrorDetails[];
|
|
706
419
|
isChatEnabled: boolean;
|
|
707
420
|
}[];
|
|
708
421
|
iteration: number;
|
|
709
422
|
timeout: number;
|
|
710
423
|
loop: number;
|
|
711
424
|
metadata: Record<string, any>;
|
|
712
|
-
|
|
713
|
-
id: string;
|
|
714
|
-
reason: string | undefined;
|
|
715
|
-
stack: string;
|
|
716
|
-
variables: ({
|
|
717
|
-
name: string;
|
|
718
|
-
type: string;
|
|
719
|
-
bytes: number;
|
|
720
|
-
preview?: string;
|
|
721
|
-
value?: unknown;
|
|
722
|
-
truncated: boolean;
|
|
723
|
-
} & ({
|
|
724
|
-
truncated: true;
|
|
725
|
-
preview: string;
|
|
726
|
-
} | {
|
|
727
|
-
truncated: false;
|
|
728
|
-
value: unknown;
|
|
729
|
-
}))[];
|
|
730
|
-
toolCall: import("./errors.js").ToolCall | undefined;
|
|
731
|
-
status: import("./snapshots.js").SnapshotStatus;
|
|
732
|
-
} | undefined;
|
|
425
|
+
sessionId: string;
|
|
733
426
|
};
|
|
734
427
|
}
|