llmz 0.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/README.md +41 -0
- package/dist/chunk-3CGLDS5T.cjs +3059 -0
- package/dist/chunk-3T465BEW.js +96 -0
- package/dist/chunk-6QDFMQHA.js +98 -0
- package/dist/chunk-7FIPXMZR.js +33 -0
- package/dist/chunk-7S3UY52U.js +3059 -0
- package/dist/chunk-A7BDFLAE.cjs +30 -0
- package/dist/chunk-BKGPO722.cjs +3079 -0
- package/dist/chunk-BOLDQGES.cjs +33 -0
- package/dist/chunk-C2TSWGYC.cjs +91 -0
- package/dist/chunk-DFZ6GX5C.js +220 -0
- package/dist/chunk-DILHJIMP.js +180 -0
- package/dist/chunk-E2B5DRIC.cjs +419 -0
- package/dist/chunk-E5W3P7EO.cjs +96 -0
- package/dist/chunk-ENFB45AI.cjs +220 -0
- package/dist/chunk-MSTBEKOQ.js +28 -0
- package/dist/chunk-PQN6HW7A.cjs +28 -0
- package/dist/chunk-Q4DEJGXD.js +344 -0
- package/dist/chunk-QPSUMPLP.js +419 -0
- package/dist/chunk-QZGFCB4T.cjs +344 -0
- package/dist/chunk-R2N2UUKC.cjs +98 -0
- package/dist/chunk-RB2L33ZR.js +3079 -0
- package/dist/chunk-RJHDQL4C.js +161 -0
- package/dist/chunk-UG2GCPHF.js +91 -0
- package/dist/chunk-UVSOAH2H.js +152 -0
- package/dist/chunk-VP6WWAE2.cjs +152 -0
- package/dist/chunk-YPOOKE3A.cjs +180 -0
- package/dist/chunk-YSQDPG26.js +30 -0
- package/dist/chunk-YUDUY7XW.cjs +284 -0
- package/dist/chunk-ZSRC3TN4.js +284 -0
- package/dist/chunk-ZUAFUOUR.cjs +161 -0
- package/dist/compiler/compiler.d.ts +28 -0
- package/dist/compiler/index.d.ts +2 -0
- package/dist/compiler/plugins/async-iterator.d.ts +4 -0
- package/dist/compiler/plugins/braces-tsx.d.ts +3 -0
- package/dist/compiler/plugins/jsx-preserve-newlines.d.ts +5 -0
- package/dist/compiler/plugins/line-tracking.d.ts +5 -0
- package/dist/compiler/plugins/replace-comment.d.ts +5 -0
- package/dist/compiler/plugins/return-async.d.ts +4 -0
- package/dist/compiler/plugins/track-tool-calls.d.ts +16 -0
- package/dist/compiler/plugins/variable-extraction.d.ts +5 -0
- package/dist/component-DWBRHLEN.cjs +9 -0
- package/dist/component-R3ZAVXUC.js +9 -0
- package/dist/component.d.ts +51 -0
- package/dist/component.default.d.ts +10 -0
- package/dist/context.d.ts +167 -0
- package/dist/dual-modes-2VDEOJ5D.js +13 -0
- package/dist/dual-modes-3MH5N6RY.cjs +13 -0
- package/dist/errors.d.ts +64 -0
- package/dist/exit-GYMXZZ4I.js +9 -0
- package/dist/exit-PQHMJEOG.cjs +9 -0
- package/dist/exit.d.ts +20 -0
- package/dist/formatting.d.ts +5 -0
- package/dist/getter.d.ts +2 -0
- package/dist/handlers.d.ts +10 -0
- package/dist/hoist.d.ts +2 -0
- package/dist/index.cjs +811 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +811 -0
- package/dist/inspect.d.ts +6 -0
- package/dist/jsx-CJ2RBODH.js +14 -0
- package/dist/jsx-PPLE5YTB.cjs +14 -0
- package/dist/jsx.d.ts +11 -0
- package/dist/llmz-EGTGPSTX.cjs +1049 -0
- package/dist/llmz-WY74UVE3.js +1049 -0
- package/dist/llmz.d.ts +41 -0
- package/dist/objects.d.ts +24 -0
- package/dist/openai.d.ts +8 -0
- package/dist/prompts/chat-mode/system.md.d.ts +2 -0
- package/dist/prompts/chat-mode/user.md.d.ts +2 -0
- package/dist/prompts/common.d.ts +6 -0
- package/dist/prompts/dual-modes.d.ts +2 -0
- package/dist/prompts/prompt.d.ts +50 -0
- package/dist/prompts/worker-mode/system.md.d.ts +2 -0
- package/dist/prompts/worker-mode/user.md.d.ts +2 -0
- package/dist/snapshots.d.ts +61 -0
- package/dist/stack-traces.d.ts +1 -0
- package/dist/tool-AY47ML65.cjs +12 -0
- package/dist/tool-WVIPESKN.js +12 -0
- package/dist/tool.d.ts +30 -0
- package/dist/transcript.d.ts +9 -0
- package/dist/truncator-MTONQESU.js +11 -0
- package/dist/truncator-ZKPOW2I3.cjs +11 -0
- package/dist/truncator.d.ts +21 -0
- package/dist/types.d.ts +131 -0
- package/dist/typings-HTYLRNIC.js +11 -0
- package/dist/typings-QRJGGNUM.cjs +11 -0
- package/dist/typings.d.ts +5 -0
- package/dist/utils-TS23YJPE.js +38 -0
- package/dist/utils-UR4IMUHC.cjs +38 -0
- package/dist/utils.d.ts +21 -0
- package/dist/vm-4JFSZAMR.cjs +13 -0
- package/dist/vm-SMMA664M.js +13 -0
- package/dist/vm.d.ts +3 -0
- package/package.json +85 -0
- package/patches/source-map-js@1.2.1.patch +16 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { type Cognitive } from '@botpress/cognitive';
|
|
2
|
+
import { Component } from './component.js';
|
|
3
|
+
import { SnapshotSignal } from './errors.js';
|
|
4
|
+
import { Exit } from './exit.js';
|
|
5
|
+
import { ValueOrGetter } from './getter.js';
|
|
6
|
+
import { HookedArray } from './handlers.js';
|
|
7
|
+
import { ObjectInstance } from './objects.js';
|
|
8
|
+
import type { OAI } from './openai.js';
|
|
9
|
+
import { Prompt } from './prompts/prompt.js';
|
|
10
|
+
import { Snapshot } from './snapshots.js';
|
|
11
|
+
import { Tool } from './tool.js';
|
|
12
|
+
import { TranscriptArray, TranscriptMessage } from './transcript.js';
|
|
13
|
+
import { ObjectMutation, Trace } from './types.js';
|
|
14
|
+
type Model = Parameters<InstanceType<typeof Cognitive>['generateContent']>[0]['model'];
|
|
15
|
+
export type IterationParameters = {
|
|
16
|
+
transcript: TranscriptArray;
|
|
17
|
+
tools: Tool[];
|
|
18
|
+
objects: ObjectInstance[];
|
|
19
|
+
exits: Exit[];
|
|
20
|
+
instructions?: string;
|
|
21
|
+
components: Component[];
|
|
22
|
+
};
|
|
23
|
+
export type IterationStatus = IterationStatuses.Pending | IterationStatuses.GenerationError | IterationStatuses.ExecutionError | IterationStatuses.InvalidCodeError | IterationStatuses.Thinking | IterationStatuses.Callback | IterationStatuses.ExitSuccess | IterationStatuses.ExitError | IterationStatuses.Aborted;
|
|
24
|
+
export declare namespace IterationStatuses {
|
|
25
|
+
type Pending = {
|
|
26
|
+
type: 'pending';
|
|
27
|
+
};
|
|
28
|
+
type GenerationError = {
|
|
29
|
+
type: 'generation_error';
|
|
30
|
+
generation_error: {
|
|
31
|
+
message: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
type InvalidCodeError = {
|
|
35
|
+
type: 'invalid_code_error';
|
|
36
|
+
invalid_code_error: {
|
|
37
|
+
message: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
type ExecutionError = {
|
|
41
|
+
type: 'execution_error';
|
|
42
|
+
execution_error: {
|
|
43
|
+
message: string;
|
|
44
|
+
stack: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
type Thinking = {
|
|
48
|
+
type: 'thinking_requested';
|
|
49
|
+
thinking_requested: {
|
|
50
|
+
reason?: string;
|
|
51
|
+
variables: Record<string, unknown>;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
type Callback = {
|
|
55
|
+
type: 'callback_requested';
|
|
56
|
+
callback_requested: {
|
|
57
|
+
signal: SnapshotSignal;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
type ExitSuccess<T = unknown> = {
|
|
61
|
+
type: 'exit_success';
|
|
62
|
+
exit_success: {
|
|
63
|
+
exit_name: string;
|
|
64
|
+
return_value: T;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
type ExitError = {
|
|
68
|
+
type: 'exit_error';
|
|
69
|
+
exit_error: {
|
|
70
|
+
exit: string;
|
|
71
|
+
return_value: unknown;
|
|
72
|
+
message: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
type Aborted = {
|
|
76
|
+
type: 'aborted';
|
|
77
|
+
aborted: {
|
|
78
|
+
reason: string;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export declare class Iteration {
|
|
83
|
+
id: string;
|
|
84
|
+
messages: OAI.Message[];
|
|
85
|
+
code?: string;
|
|
86
|
+
traces: HookedArray<Trace>;
|
|
87
|
+
variables: Record<string, any>;
|
|
88
|
+
started_ts: number;
|
|
89
|
+
ended_ts?: number;
|
|
90
|
+
status: IterationStatus;
|
|
91
|
+
private _mutations;
|
|
92
|
+
get mutations(): ObjectMutation[];
|
|
93
|
+
trackMutation(mutation: ObjectMutation): void;
|
|
94
|
+
private _parameters;
|
|
95
|
+
get transcript(): TranscriptArray;
|
|
96
|
+
get tools(): Tool<unknown, unknown>[];
|
|
97
|
+
get objects(): ObjectInstance[];
|
|
98
|
+
get exits(): Exit<unknown>[];
|
|
99
|
+
get instructions(): string | undefined;
|
|
100
|
+
llm?: {
|
|
101
|
+
started_at: number;
|
|
102
|
+
ended_at: number;
|
|
103
|
+
status: 'success' | 'error';
|
|
104
|
+
cached: boolean;
|
|
105
|
+
tokens: number;
|
|
106
|
+
spend: number;
|
|
107
|
+
output: string;
|
|
108
|
+
model: string;
|
|
109
|
+
};
|
|
110
|
+
hasExited(this: this): this is this & {
|
|
111
|
+
status: IterationStatuses.ExitSuccess;
|
|
112
|
+
};
|
|
113
|
+
hasExitedWith<R>(this: this, exit: Exit<R>): this is {
|
|
114
|
+
status: IterationStatuses.ExitSuccess<R>;
|
|
115
|
+
} & this;
|
|
116
|
+
isSuccessful(this: this): this is this & {
|
|
117
|
+
status: IterationStatuses.ExitSuccess | IterationStatuses.Callback | IterationStatuses.Thinking;
|
|
118
|
+
};
|
|
119
|
+
isFailed(this: this): this is this & {
|
|
120
|
+
status: IterationStatuses.GenerationError | IterationStatuses.ExecutionError | IterationStatuses.InvalidCodeError | IterationStatuses.ExitError | IterationStatuses.Aborted;
|
|
121
|
+
};
|
|
122
|
+
get duration(): string;
|
|
123
|
+
get error(): string | null;
|
|
124
|
+
get isChatEnabled(): boolean;
|
|
125
|
+
constructor(props: {
|
|
126
|
+
id: string;
|
|
127
|
+
parameters: IterationParameters;
|
|
128
|
+
messages: OAI.Message[];
|
|
129
|
+
variables: Record<string, any>;
|
|
130
|
+
});
|
|
131
|
+
end(status: IterationStatus): void;
|
|
132
|
+
}
|
|
133
|
+
export declare class Context {
|
|
134
|
+
id: string;
|
|
135
|
+
transcript?: ValueOrGetter<TranscriptArray, Context>;
|
|
136
|
+
instructions?: ValueOrGetter<string, Context>;
|
|
137
|
+
objects?: ValueOrGetter<ObjectInstance[], Context>;
|
|
138
|
+
tools?: ValueOrGetter<Tool[], Context>;
|
|
139
|
+
exits?: ValueOrGetter<Exit[], Context>;
|
|
140
|
+
components?: ValueOrGetter<Component[], Context>;
|
|
141
|
+
version: Prompt;
|
|
142
|
+
loop: number;
|
|
143
|
+
temperature: number;
|
|
144
|
+
model?: Model;
|
|
145
|
+
metadata: Record<string, any>;
|
|
146
|
+
snapshot?: Snapshot;
|
|
147
|
+
iteration: number;
|
|
148
|
+
iterations: Iteration[];
|
|
149
|
+
nextIteration(): Promise<Iteration>;
|
|
150
|
+
private _getIterationVariables;
|
|
151
|
+
private _getIterationMessages;
|
|
152
|
+
private _refreshIterationParameters;
|
|
153
|
+
constructor(props: {
|
|
154
|
+
instructions?: ValueOrGetter<string, Context>;
|
|
155
|
+
objects?: ValueOrGetter<ObjectInstance[], Context>;
|
|
156
|
+
tools?: ValueOrGetter<Tool[], Context>;
|
|
157
|
+
exits?: ValueOrGetter<Exit[], Context>;
|
|
158
|
+
transcript?: ValueOrGetter<TranscriptMessage[], Context>;
|
|
159
|
+
components?: ValueOrGetter<Component[], Context>;
|
|
160
|
+
loop?: number;
|
|
161
|
+
temperature?: number;
|
|
162
|
+
model?: Model;
|
|
163
|
+
metadata?: Record<string, any>;
|
|
164
|
+
snapshot?: Snapshot;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DualModePrompt
|
|
3
|
+
} from "./chunk-QPSUMPLP.js";
|
|
4
|
+
import "./chunk-Q4DEJGXD.js";
|
|
5
|
+
import "./chunk-MSTBEKOQ.js";
|
|
6
|
+
import "./chunk-3T465BEW.js";
|
|
7
|
+
import "./chunk-UVSOAH2H.js";
|
|
8
|
+
import "./chunk-DFZ6GX5C.js";
|
|
9
|
+
import "./chunk-7S3UY52U.js";
|
|
10
|
+
import "./chunk-YSQDPG26.js";
|
|
11
|
+
export {
|
|
12
|
+
DualModePrompt
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkE2B5DRICcjs = require('./chunk-E2B5DRIC.cjs');
|
|
4
|
+
require('./chunk-QZGFCB4T.cjs');
|
|
5
|
+
require('./chunk-PQN6HW7A.cjs');
|
|
6
|
+
require('./chunk-E5W3P7EO.cjs');
|
|
7
|
+
require('./chunk-VP6WWAE2.cjs');
|
|
8
|
+
require('./chunk-ENFB45AI.cjs');
|
|
9
|
+
require('./chunk-3CGLDS5T.cjs');
|
|
10
|
+
require('./chunk-A7BDFLAE.cjs');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports.DualModePrompt = _chunkE2B5DRICcjs.DualModePrompt;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { JSONSchema } from '@bpinternal/zui';
|
|
2
|
+
import { type Assignment } from './compiler/plugins/track-tool-calls.js';
|
|
3
|
+
export type ToolCall = {
|
|
4
|
+
name: string;
|
|
5
|
+
inputSchema?: JSONSchema;
|
|
6
|
+
outputSchema?: JSONSchema;
|
|
7
|
+
input?: unknown;
|
|
8
|
+
assignment?: Assignment;
|
|
9
|
+
};
|
|
10
|
+
export declare namespace Signals {
|
|
11
|
+
function isWrappedError(error: Error): boolean;
|
|
12
|
+
function serializeError(error: Error): string;
|
|
13
|
+
function maybeDeserializeError(error: unknown): any;
|
|
14
|
+
}
|
|
15
|
+
export declare class VMSignal extends Error {
|
|
16
|
+
message: string;
|
|
17
|
+
/**
|
|
18
|
+
* The code that was executed by the VM up to the point of the signal
|
|
19
|
+
*/
|
|
20
|
+
truncatedCode: string;
|
|
21
|
+
/** The current tool call, if any */
|
|
22
|
+
toolCall?: ToolCall;
|
|
23
|
+
/**
|
|
24
|
+
* Contains all the declared and executed variables during the VM execution
|
|
25
|
+
* See file plugins/variable-extraction.ts for more details
|
|
26
|
+
*/
|
|
27
|
+
variables: {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
};
|
|
30
|
+
constructor(message: string);
|
|
31
|
+
}
|
|
32
|
+
/** Request a snapshot from inside a tool call */
|
|
33
|
+
export declare class SnapshotSignal extends VMSignal {
|
|
34
|
+
constructor(message: string);
|
|
35
|
+
}
|
|
36
|
+
/** Loop means LLMz will continue the execution (unless it exhausted its iterations) */
|
|
37
|
+
export declare class VMLoopSignal extends VMSignal {
|
|
38
|
+
constructor(message: string);
|
|
39
|
+
}
|
|
40
|
+
export declare class ThinkSignal extends VMLoopSignal {
|
|
41
|
+
reason: string;
|
|
42
|
+
context?: any | undefined;
|
|
43
|
+
constructor(reason: string, context?: any | undefined);
|
|
44
|
+
toString(): string;
|
|
45
|
+
}
|
|
46
|
+
export declare class CodeExecutionError extends Error {
|
|
47
|
+
code: string;
|
|
48
|
+
stacktrace: string;
|
|
49
|
+
constructor(message: string, code: string, stacktrace: string);
|
|
50
|
+
}
|
|
51
|
+
export declare class InvalidCodeError extends Error {
|
|
52
|
+
code: string;
|
|
53
|
+
constructor(message: string, code: string);
|
|
54
|
+
}
|
|
55
|
+
export declare class LoopExceededError extends Error {
|
|
56
|
+
constructor();
|
|
57
|
+
}
|
|
58
|
+
export declare class CodeFormattingError extends Error {
|
|
59
|
+
code: string;
|
|
60
|
+
constructor(message: string, code: string);
|
|
61
|
+
}
|
|
62
|
+
export declare class AssignmentError extends Error {
|
|
63
|
+
constructor(message: string);
|
|
64
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkR2N2UUKCcjs = require('./chunk-R2N2UUKC.cjs');
|
|
4
|
+
require('./chunk-ENFB45AI.cjs');
|
|
5
|
+
require('./chunk-3CGLDS5T.cjs');
|
|
6
|
+
require('./chunk-A7BDFLAE.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.Exit = _chunkR2N2UUKCcjs.Exit;
|
package/dist/exit.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type JSONSchema } from '@bpinternal/zui';
|
|
2
|
+
import { ZuiType } from './types.js';
|
|
3
|
+
export declare class Exit<T = unknown> {
|
|
4
|
+
name: string;
|
|
5
|
+
aliases: string[];
|
|
6
|
+
description: string;
|
|
7
|
+
metadata: Record<string, unknown>;
|
|
8
|
+
schema?: JSONSchema;
|
|
9
|
+
get zSchema(): import("@bpinternal/zui").ZodTypeAny | undefined;
|
|
10
|
+
rename(name: string): this;
|
|
11
|
+
clone(): Exit<any>;
|
|
12
|
+
constructor(props: {
|
|
13
|
+
name: string;
|
|
14
|
+
aliases?: string[];
|
|
15
|
+
description: string;
|
|
16
|
+
metadata?: Record<string, unknown>;
|
|
17
|
+
schema?: ZuiType<T>;
|
|
18
|
+
});
|
|
19
|
+
static withUniqueNames: (exits: Exit[]) => Exit<unknown>[];
|
|
20
|
+
}
|
package/dist/getter.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type UnsubscribeFn = () => void;
|
|
2
|
+
type EventHandler<T> = (event: T) => void;
|
|
3
|
+
export type SubscribeFn<T> = (fn: EventHandler<T>) => UnsubscribeFn;
|
|
4
|
+
export declare class HookedArray<T> extends Array<T> {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(...items: T[]);
|
|
7
|
+
push(...items: T[]): number;
|
|
8
|
+
onPush(fn: EventHandler<T[]>): UnsubscribeFn;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
package/dist/hoist.d.ts
ADDED