llmz 0.0.6 → 0.0.8
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 +24 -3
- package/dist/chat.d.ts +2 -2
- package/dist/{chunk-P7J2WCBB.cjs → chunk-276Q6EWP.cjs} +6 -2
- package/dist/{chunk-HYVKY3W6.cjs → chunk-4L6D2A6O.cjs} +15 -15
- package/dist/{chunk-5TRUJES5.js → chunk-4MNIJGK6.js} +6 -2
- package/dist/{chunk-4QTK5ALH.cjs → chunk-C6WNNTEV.cjs} +23 -22
- package/dist/{chunk-HP7RKM25.js → chunk-GGWM6X2K.js} +32 -1
- package/dist/{chunk-4I7UPBLN.cjs → chunk-GWFYZDUR.cjs} +9 -8
- package/dist/{chunk-CH5T6SPC.cjs → chunk-HJKOSEH2.cjs} +89 -61
- package/dist/{chunk-UNMKB2DA.js → chunk-IH2WQFO5.js} +2 -2
- package/dist/{chunk-QBXIE6EY.js → chunk-JAGB2AOU.js} +16 -15
- package/dist/{chunk-FIVFS4HG.cjs → chunk-JGVAZO4X.cjs} +5 -5
- package/dist/{chunk-S6FOL2HY.js → chunk-JMSZKB4T.js} +7 -6
- package/dist/{chunk-WLUVY5QU.js → chunk-KH6JQYQA.js} +62 -21
- package/dist/{chunk-XJNRORSK.js → chunk-PRVFVXT4.js} +76 -48
- package/dist/{chunk-6WT5VZBG.cjs → chunk-SHJDRZF5.cjs} +81 -40
- package/dist/{chunk-QT4QF3YA.js → chunk-SNDVQU5A.js} +4 -4
- package/dist/{chunk-EJRCDWBA.cjs → chunk-ZRCU35UV.cjs} +32 -1
- package/dist/component-R4WTW6DZ.cjs +18 -0
- package/dist/{component-R2Y74VUI.js → component-WFVDVSDK.js} +5 -3
- package/dist/component.d.ts +6 -0
- package/dist/context.d.ts +3 -4
- package/dist/{dual-modes-ZUQKPJFH.js → dual-modes-T53P72CH.js} +4 -4
- package/dist/dual-modes-VLIGPIHX.cjs +12 -0
- package/dist/errors.d.ts +3 -3
- package/dist/exit-TRXEU4OU.cjs +8 -0
- package/dist/{exit-OIYZLBVJ.js → exit-YORW76T3.js} +2 -2
- package/dist/exit.d.ts +2 -2
- package/dist/index.cjs +40 -38
- package/dist/index.d.ts +2 -1
- package/dist/index.js +21 -19
- package/dist/{llmz-CPMVYIOJ.cjs → llmz-QLZBDG2Z.cjs} +28 -33
- package/dist/{llmz-LAN4WDFW.js → llmz-ROOX7RYI.js} +17 -22
- package/dist/llmz.d.ts +1 -1
- package/dist/prompts/chat-mode/system.md.d.ts +1 -1
- package/dist/prompts/prompt.d.ts +13 -8
- package/dist/prompts/worker-mode/system.md.d.ts +1 -1
- package/dist/{tool-LY77IWV2.js → tool-N6ODRRGH.js} +3 -3
- package/dist/{tool-SWJYOR2Z.cjs → tool-QP4MVRWI.cjs} +4 -4
- package/dist/tool.d.ts +4 -3
- package/dist/transcript.d.ts +34 -7
- package/dist/truncator-DUMWEGQO.cjs +10 -0
- package/dist/{truncator-WAL2GCUY.js → truncator-IY2MXOMC.js} +2 -2
- package/dist/truncator.d.ts +2 -3
- package/dist/{typings-XR6CYHW4.cjs → typings-2CPHOFDN.cjs} +3 -3
- package/dist/{typings-AIV2OASX.js → typings-GDMY6VY2.js} +2 -2
- package/dist/utils-A7WNEFTA.cjs +39 -0
- package/dist/{utils-L5GLCS3C.js → utils-N24IHDFA.js} +3 -1
- package/dist/utils.d.ts +5 -3
- package/package.json +5 -3
- package/dist/component-TSNW3SC7.cjs +0 -16
- package/dist/dual-modes-UHNDHNIF.cjs +0 -12
- package/dist/exit-KJ4COC5N.cjs +0 -8
- package/dist/openai.d.ts +0 -8
- package/dist/truncator-NYN7BGKJ.cjs +0 -10
- package/dist/utils-QC4I2L6R.cjs +0 -37
package/dist/index.cjs
CHANGED
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
12
|
-
require('./chunk-
|
|
11
|
+
var _chunkHJKOSEH2cjs = require('./chunk-HJKOSEH2.cjs');
|
|
12
|
+
require('./chunk-SHJDRZF5.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkC6WNNTEVcjs = require('./chunk-C6WNNTEV.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunk4L6D2A6Ocjs = require('./chunk-4L6D2A6O.cjs');
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
@@ -26,20 +26,21 @@ var _chunkJDABP4SDcjs = require('./chunk-JDABP4SD.cjs');
|
|
|
26
26
|
require('./chunk-IKSIOIIP.cjs');
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _chunkGWFYZDURcjs = require('./chunk-GWFYZDUR.cjs');
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
var _chunkZRCU35UVcjs = require('./chunk-ZRCU35UV.cjs');
|
|
36
37
|
require('./chunk-KMZDFWYZ.cjs');
|
|
37
|
-
require('./chunk-
|
|
38
|
+
require('./chunk-JGVAZO4X.cjs');
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
|
|
42
|
-
var
|
|
43
|
+
var _chunk276Q6EWPcjs = require('./chunk-276Q6EWP.cjs');
|
|
43
44
|
|
|
44
45
|
|
|
45
46
|
|
|
@@ -295,7 +296,7 @@ async function hoistTypings(code, formatOptions) {
|
|
|
295
296
|
break;
|
|
296
297
|
}
|
|
297
298
|
}
|
|
298
|
-
return
|
|
299
|
+
return _chunk4L6D2A6Ocjs.formatTypings.call(void 0, code, formatOptions);
|
|
299
300
|
}
|
|
300
301
|
|
|
301
302
|
// src/objects.ts
|
|
@@ -308,7 +309,7 @@ var ObjectInstance = class {
|
|
|
308
309
|
|
|
309
310
|
constructor(props) {
|
|
310
311
|
var _a;
|
|
311
|
-
if (!
|
|
312
|
+
if (!_chunk276Q6EWPcjs.isValidIdentifier.call(void 0, props.name)) {
|
|
312
313
|
throw new Error(
|
|
313
314
|
`Invalid name for tool ${props.name}. A tool name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
314
315
|
);
|
|
@@ -341,7 +342,7 @@ var ObjectInstance = class {
|
|
|
341
342
|
if (props.properties.filter((p) => p.name === prop.name).length > 1) {
|
|
342
343
|
throw new Error(`Duplicate property name "${prop.name}" in tool ${props.name}`);
|
|
343
344
|
}
|
|
344
|
-
if (!
|
|
345
|
+
if (!_chunk276Q6EWPcjs.isValidIdentifier.call(void 0, prop.name)) {
|
|
345
346
|
throw new Error(
|
|
346
347
|
`Invalid name for property ${prop.name}. A property name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
347
348
|
);
|
|
@@ -365,7 +366,7 @@ var ObjectInstance = class {
|
|
|
365
366
|
this.description = props.description;
|
|
366
367
|
this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
|
|
367
368
|
this.properties = props.properties;
|
|
368
|
-
this.tools =
|
|
369
|
+
this.tools = _chunkC6WNNTEVcjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
|
|
369
370
|
}
|
|
370
371
|
async getTypings() {
|
|
371
372
|
return getObjectTypings(this).withProperties().withTools().build();
|
|
@@ -387,11 +388,11 @@ function getObjectTypings(obj) {
|
|
|
387
388
|
for (const prop of _nullishCoalesce(obj.properties, () => ( []))) {
|
|
388
389
|
const description = _nullishCoalesce(prop.description, () => ( ""));
|
|
389
390
|
if (description == null ? void 0 : description.trim().length) {
|
|
390
|
-
typings.push(
|
|
391
|
+
typings.push(_chunk276Q6EWPcjs.getMultilineComment.call(void 0, description));
|
|
391
392
|
}
|
|
392
393
|
let type = "unknown";
|
|
393
394
|
if (prop.type) {
|
|
394
|
-
type = await
|
|
395
|
+
type = await _chunk4L6D2A6Ocjs.getTypings.call(void 0, prop.type, {});
|
|
395
396
|
} else if (prop.value !== void 0) {
|
|
396
397
|
type = typeof prop.value;
|
|
397
398
|
}
|
|
@@ -411,7 +412,7 @@ function getObjectTypings(obj) {
|
|
|
411
412
|
typings.push("");
|
|
412
413
|
for (const tool of obj.tools) {
|
|
413
414
|
const fnType = _zui.z.function(tool.zInput, tool.zOutput).title(tool.name).describe(_nullishCoalesce(tool.description, () => ( "")));
|
|
414
|
-
let temp = await
|
|
415
|
+
let temp = await _chunk4L6D2A6Ocjs.getTypings.call(void 0, fnType, {
|
|
415
416
|
declaration: true
|
|
416
417
|
});
|
|
417
418
|
temp = temp.replace("declare function ", "function ");
|
|
@@ -432,9 +433,9 @@ function getObjectTypings(obj) {
|
|
|
432
433
|
typings.push("}" + closingBracket);
|
|
433
434
|
let header = "";
|
|
434
435
|
if ((_a = obj.description) == null ? void 0 : _a.trim().length) {
|
|
435
|
-
header =
|
|
436
|
+
header = _chunk276Q6EWPcjs.getMultilineComment.call(void 0, obj.description);
|
|
436
437
|
}
|
|
437
|
-
return
|
|
438
|
+
return _chunk4L6D2A6Ocjs.formatTypings.call(void 0,
|
|
438
439
|
`${header}
|
|
439
440
|
export namespace ${obj.name} {
|
|
440
441
|
${body}
|
|
@@ -465,7 +466,7 @@ function getObjectTypings(obj) {
|
|
|
465
466
|
}
|
|
466
467
|
function embedPropertyValue(property) {
|
|
467
468
|
if (typeof property.value === "string") {
|
|
468
|
-
return
|
|
469
|
+
return _chunk276Q6EWPcjs.escapeString.call(void 0, property.value);
|
|
469
470
|
}
|
|
470
471
|
if (Number.isNaN(property.value)) {
|
|
471
472
|
return "NaN";
|
|
@@ -483,7 +484,7 @@ function embedPropertyValue(property) {
|
|
|
483
484
|
return `new Date('${property.value.toISOString()}')`;
|
|
484
485
|
}
|
|
485
486
|
if (property.value instanceof RegExp) {
|
|
486
|
-
return `new RegExp(${
|
|
487
|
+
return `new RegExp(${_chunk276Q6EWPcjs.escapeString.call(void 0, property.value.source)}, ${_chunk276Q6EWPcjs.escapeString.call(void 0, property.value.flags)})`;
|
|
487
488
|
}
|
|
488
489
|
if (property.value === null) {
|
|
489
490
|
return "null";
|
|
@@ -501,7 +502,7 @@ function embedPropertyValue(property) {
|
|
|
501
502
|
return `${property.value}n`;
|
|
502
503
|
}
|
|
503
504
|
if (property.value instanceof Error) {
|
|
504
|
-
return `Error(${
|
|
505
|
+
return `Error(${_chunk276Q6EWPcjs.escapeString.call(void 0, property.value.message)})`;
|
|
505
506
|
}
|
|
506
507
|
if (property.value instanceof Map) {
|
|
507
508
|
return `new Map(${JSON.stringify(Array.from(property.value.entries()))})`;
|
|
@@ -648,7 +649,7 @@ var CitationsManager = (_class = class {constructor() { _class.prototype.__init.
|
|
|
648
649
|
|
|
649
650
|
// src/component.default.ts
|
|
650
651
|
|
|
651
|
-
var Button = new (0,
|
|
652
|
+
var Button = new (0, _chunkZRCU35UVcjs.Component)({
|
|
652
653
|
type: "leaf",
|
|
653
654
|
description: "A button component that can perform actions when clicked",
|
|
654
655
|
name: "Button",
|
|
@@ -678,7 +679,7 @@ var Button = new (0, _chunkEJRCDWBAcjs.Component)({
|
|
|
678
679
|
})
|
|
679
680
|
}
|
|
680
681
|
});
|
|
681
|
-
var Image = new (0,
|
|
682
|
+
var Image = new (0, _chunkZRCU35UVcjs.Component)({
|
|
682
683
|
type: "leaf",
|
|
683
684
|
name: "Image",
|
|
684
685
|
description: "Displays an image from a URL.",
|
|
@@ -699,7 +700,7 @@ var Image = new (0, _chunkEJRCDWBAcjs.Component)({
|
|
|
699
700
|
})
|
|
700
701
|
}
|
|
701
702
|
});
|
|
702
|
-
var File = new (0,
|
|
703
|
+
var File = new (0, _chunkZRCU35UVcjs.Component)({
|
|
703
704
|
type: "leaf",
|
|
704
705
|
name: "File",
|
|
705
706
|
description: "Sends a downloadable file to the user.",
|
|
@@ -720,7 +721,7 @@ var File = new (0, _chunkEJRCDWBAcjs.Component)({
|
|
|
720
721
|
})
|
|
721
722
|
}
|
|
722
723
|
});
|
|
723
|
-
var Video = new (0,
|
|
724
|
+
var Video = new (0, _chunkZRCU35UVcjs.Component)({
|
|
724
725
|
type: "leaf",
|
|
725
726
|
name: "Video",
|
|
726
727
|
description: "Embeds a video from a URL.",
|
|
@@ -741,7 +742,7 @@ var Video = new (0, _chunkEJRCDWBAcjs.Component)({
|
|
|
741
742
|
})
|
|
742
743
|
}
|
|
743
744
|
});
|
|
744
|
-
var Audio = new (0,
|
|
745
|
+
var Audio = new (0, _chunkZRCU35UVcjs.Component)({
|
|
745
746
|
type: "leaf",
|
|
746
747
|
name: "Audio",
|
|
747
748
|
description: "Plays an audio clip from a URL.",
|
|
@@ -762,7 +763,7 @@ var Audio = new (0, _chunkEJRCDWBAcjs.Component)({
|
|
|
762
763
|
})
|
|
763
764
|
}
|
|
764
765
|
});
|
|
765
|
-
var Card = new (0,
|
|
766
|
+
var Card = new (0, _chunkZRCU35UVcjs.Component)({
|
|
766
767
|
type: "container",
|
|
767
768
|
name: "Card",
|
|
768
769
|
description: "A visual card component that can include an image and buttons.",
|
|
@@ -797,7 +798,7 @@ var Card = new (0, _chunkEJRCDWBAcjs.Component)({
|
|
|
797
798
|
]
|
|
798
799
|
}
|
|
799
800
|
});
|
|
800
|
-
var Carousel = new (0,
|
|
801
|
+
var Carousel = new (0, _chunkZRCU35UVcjs.Component)({
|
|
801
802
|
type: "container",
|
|
802
803
|
name: "Carousel",
|
|
803
804
|
description: "A virtual container for displaying 1 to 10 Card components as a carousel.",
|
|
@@ -830,7 +831,7 @@ var Carousel = new (0, _chunkEJRCDWBAcjs.Component)({
|
|
|
830
831
|
]
|
|
831
832
|
}
|
|
832
833
|
});
|
|
833
|
-
var Text = new (0,
|
|
834
|
+
var Text = new (0, _chunkZRCU35UVcjs.Component)({
|
|
834
835
|
type: "default",
|
|
835
836
|
name: "Message",
|
|
836
837
|
aliases: ["Text", "Markdown"],
|
|
@@ -876,20 +877,20 @@ var Chat = class {
|
|
|
876
877
|
|
|
877
878
|
// src/index.ts
|
|
878
879
|
var execute = async (props) => {
|
|
879
|
-
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-
|
|
880
|
+
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-QLZBDG2Z.cjs")));
|
|
880
881
|
return executeContext(props);
|
|
881
882
|
};
|
|
882
883
|
var init = async () => {
|
|
883
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-
|
|
884
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./component-
|
|
885
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-
|
|
886
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-
|
|
884
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-QLZBDG2Z.cjs")));
|
|
885
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./component-R4WTW6DZ.cjs")));
|
|
886
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-QP4MVRWI.cjs")));
|
|
887
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-TRXEU4OU.cjs")));
|
|
887
888
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./jsx-AJAXBWFE.cjs")));
|
|
888
889
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-2DLG7V4G.cjs")));
|
|
889
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-
|
|
890
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-
|
|
891
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-
|
|
892
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-
|
|
890
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-A7WNEFTA.cjs")));
|
|
891
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-DUMWEGQO.cjs")));
|
|
892
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-2CPHOFDN.cjs")));
|
|
893
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-VLIGPIHX.cjs")));
|
|
893
894
|
};
|
|
894
895
|
|
|
895
896
|
|
|
@@ -916,4 +917,5 @@ var init = async () => {
|
|
|
916
917
|
|
|
917
918
|
|
|
918
919
|
|
|
919
|
-
|
|
920
|
+
|
|
921
|
+
exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkZRCU35UVcjs.Component; exports.DefaultComponents = DefaultComponents; exports.DefaultExit = _chunkHJKOSEH2cjs.DefaultExit; exports.ErrorExecutionResult = _chunkHJKOSEH2cjs.ErrorExecutionResult; exports.ExecutionResult = _chunkHJKOSEH2cjs.ExecutionResult; exports.Exit = _chunkGWFYZDURcjs.Exit; exports.ListenExit = _chunkHJKOSEH2cjs.ListenExit; exports.LoopExceededError = _chunkJDABP4SDcjs.LoopExceededError; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunkHJKOSEH2cjs.PartialExecutionResult; exports.Snapshot = _chunkHJKOSEH2cjs.Snapshot; exports.SnapshotSignal = _chunkJDABP4SDcjs.SnapshotSignal; exports.SuccessExecutionResult = _chunkHJKOSEH2cjs.SuccessExecutionResult; exports.ThinkExit = _chunkHJKOSEH2cjs.ThinkExit; exports.ThinkSignal = _chunkJDABP4SDcjs.ThinkSignal; exports.Tool = _chunkC6WNNTEVcjs.Tool; exports.assertValidComponent = _chunkZRCU35UVcjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunkHJKOSEH2cjs.getValue; exports.init = init; exports.isAnyComponent = _chunkZRCU35UVcjs.isAnyComponent; exports.isComponent = _chunkZRCU35UVcjs.isComponent; exports.renderToTsx = _chunkZRCU35UVcjs.renderToTsx;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,14 @@ export { Tool } from './tool.js';
|
|
|
2
2
|
export { Exit, ExitResult } from './exit.js';
|
|
3
3
|
export { ObjectInstance } from './objects.js';
|
|
4
4
|
export { SnapshotSignal, ThinkSignal, LoopExceededError } from './errors.js';
|
|
5
|
-
export { Component, RenderedComponent, LeafComponentDefinition, ContainerComponentDefinition, DefaultComponentDefinition, ComponentDefinition, assertValidComponent, isComponent, isAnyComponent, } from './component.js';
|
|
5
|
+
export { Component, RenderedComponent, LeafComponentDefinition, ContainerComponentDefinition, DefaultComponentDefinition, ComponentDefinition, assertValidComponent, isComponent, isAnyComponent, renderToTsx, } from './component.js';
|
|
6
6
|
export { Citation, CitationsManager } from './citations.js';
|
|
7
7
|
export { DefaultComponents } from './component.default.js';
|
|
8
8
|
export { Snapshot } from './snapshots.js';
|
|
9
9
|
export { Chat, type MessageHandler } from './chat.js';
|
|
10
10
|
import { type ExecutionProps } from './llmz.js';
|
|
11
11
|
import { ExecutionResult } from './result.js';
|
|
12
|
+
export { Transcript } from './transcript.js';
|
|
12
13
|
export { ErrorExecutionResult, ExecutionResult, PartialExecutionResult, SuccessExecutionResult } from './result.js';
|
|
13
14
|
export { Trace } from './types.js';
|
|
14
15
|
export { type Iteration, ListenExit, ThinkExit, DefaultExit, IterationStatuses, IterationStatus } from './context.js';
|
package/dist/index.js
CHANGED
|
@@ -8,15 +8,15 @@ import {
|
|
|
8
8
|
SuccessExecutionResult,
|
|
9
9
|
ThinkExit,
|
|
10
10
|
getValue
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-PRVFVXT4.js";
|
|
12
|
+
import "./chunk-KH6JQYQA.js";
|
|
13
13
|
import {
|
|
14
14
|
Tool
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-JAGB2AOU.js";
|
|
16
16
|
import {
|
|
17
17
|
formatTypings,
|
|
18
18
|
getTypings
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-IH2WQFO5.js";
|
|
20
20
|
import {
|
|
21
21
|
CodeFormattingError,
|
|
22
22
|
LoopExceededError,
|
|
@@ -26,20 +26,21 @@ import {
|
|
|
26
26
|
import "./chunk-JQBT7UWN.js";
|
|
27
27
|
import {
|
|
28
28
|
Exit
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-JMSZKB4T.js";
|
|
30
30
|
import {
|
|
31
31
|
Component,
|
|
32
32
|
assertValidComponent,
|
|
33
33
|
isAnyComponent,
|
|
34
|
-
isComponent
|
|
35
|
-
|
|
34
|
+
isComponent,
|
|
35
|
+
renderToTsx
|
|
36
|
+
} from "./chunk-GGWM6X2K.js";
|
|
36
37
|
import "./chunk-ORQP26SZ.js";
|
|
37
|
-
import "./chunk-
|
|
38
|
+
import "./chunk-SNDVQU5A.js";
|
|
38
39
|
import {
|
|
39
40
|
escapeString,
|
|
40
41
|
getMultilineComment,
|
|
41
42
|
isValidIdentifier
|
|
42
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-4MNIJGK6.js";
|
|
43
44
|
import {
|
|
44
45
|
cloneDeep_default,
|
|
45
46
|
upperFirst_default
|
|
@@ -876,20 +877,20 @@ var Chat = class {
|
|
|
876
877
|
|
|
877
878
|
// src/index.ts
|
|
878
879
|
var execute = async (props) => {
|
|
879
|
-
const { executeContext } = await import("./llmz-
|
|
880
|
+
const { executeContext } = await import("./llmz-ROOX7RYI.js");
|
|
880
881
|
return executeContext(props);
|
|
881
882
|
};
|
|
882
883
|
var init = async () => {
|
|
883
|
-
await import("./llmz-
|
|
884
|
-
await import("./component-
|
|
885
|
-
await import("./tool-
|
|
886
|
-
await import("./exit-
|
|
884
|
+
await import("./llmz-ROOX7RYI.js");
|
|
885
|
+
await import("./component-WFVDVSDK.js");
|
|
886
|
+
await import("./tool-N6ODRRGH.js");
|
|
887
|
+
await import("./exit-YORW76T3.js");
|
|
887
888
|
await import("./jsx-AEHVFB3L.js");
|
|
888
889
|
await import("./vm-FLBMZUA2.js");
|
|
889
|
-
await import("./utils-
|
|
890
|
-
await import("./truncator-
|
|
891
|
-
await import("./typings-
|
|
892
|
-
await import("./dual-modes-
|
|
890
|
+
await import("./utils-N24IHDFA.js");
|
|
891
|
+
await import("./truncator-IY2MXOMC.js");
|
|
892
|
+
await import("./typings-GDMY6VY2.js");
|
|
893
|
+
await import("./dual-modes-T53P72CH.js");
|
|
893
894
|
};
|
|
894
895
|
export {
|
|
895
896
|
Chat,
|
|
@@ -915,5 +916,6 @@ export {
|
|
|
915
916
|
getValue,
|
|
916
917
|
init,
|
|
917
918
|
isAnyComponent,
|
|
918
|
-
isComponent
|
|
919
|
+
isComponent,
|
|
920
|
+
renderToTsx
|
|
919
921
|
};
|
|
@@ -7,10 +7,10 @@ var _chunkBEPRLBPKcjs = require('./chunk-BEPRLBPK.cjs');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
require('./chunk-
|
|
12
|
-
require('./chunk-
|
|
13
|
-
require('./chunk-
|
|
10
|
+
var _chunkHJKOSEH2cjs = require('./chunk-HJKOSEH2.cjs');
|
|
11
|
+
require('./chunk-SHJDRZF5.cjs');
|
|
12
|
+
require('./chunk-C6WNNTEV.cjs');
|
|
13
|
+
require('./chunk-4L6D2A6O.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -24,16 +24,16 @@ var _chunkJDABP4SDcjs = require('./chunk-JDABP4SD.cjs');
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
var _chunkIKSIOIIPcjs = require('./chunk-IKSIOIIP.cjs');
|
|
27
|
-
require('./chunk-
|
|
28
|
-
require('./chunk-
|
|
27
|
+
require('./chunk-GWFYZDUR.cjs');
|
|
28
|
+
require('./chunk-ZRCU35UV.cjs');
|
|
29
29
|
require('./chunk-KMZDFWYZ.cjs');
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _chunkJGVAZO4Xcjs = require('./chunk-JGVAZO4X.cjs');
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
var
|
|
36
|
+
var _chunk276Q6EWPcjs = require('./chunk-276Q6EWP.cjs');
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
@@ -60,7 +60,7 @@ var getModelOutputLimit = (inputLength) => _chunkUQOBUJIQcjs.clamp_default.call(
|
|
|
60
60
|
);
|
|
61
61
|
var executeContext = async (props) => {
|
|
62
62
|
var _a, _b;
|
|
63
|
-
await
|
|
63
|
+
await _chunk276Q6EWPcjs.init.call(void 0, );
|
|
64
64
|
const result = await _executeContext(props);
|
|
65
65
|
try {
|
|
66
66
|
(_b = (_a = result.context.chat) == null ? void 0 : _a.onExecutionDone) == null ? void 0 : _b.call(_a, result);
|
|
@@ -71,9 +71,9 @@ var executeContext = async (props) => {
|
|
|
71
71
|
var _executeContext = async (props) => {
|
|
72
72
|
var _a, _b, _c, _d;
|
|
73
73
|
const { signal, onIterationEnd, onTrace, onExit, onBeforeExecution } = props;
|
|
74
|
-
const cognitive = props.client
|
|
74
|
+
const cognitive = _cognitive.Cognitive.isCognitiveClient(props.client) ? props.client : new (0, _cognitive.Cognitive)({ client: props.client });
|
|
75
75
|
const cleanups = [];
|
|
76
|
-
const ctx = new (0,
|
|
76
|
+
const ctx = new (0, _chunkHJKOSEH2cjs.Context)({
|
|
77
77
|
chat: props.chat,
|
|
78
78
|
instructions: props.instructions,
|
|
79
79
|
objects: props.objects,
|
|
@@ -88,7 +88,7 @@ var _executeContext = async (props) => {
|
|
|
88
88
|
try {
|
|
89
89
|
while (true) {
|
|
90
90
|
if (ctx.iterations.length >= ctx.loop) {
|
|
91
|
-
return new (0,
|
|
91
|
+
return new (0, _chunkHJKOSEH2cjs.ErrorExecutionResult)(ctx, new (0, _chunkJDABP4SDcjs.LoopExceededError)());
|
|
92
92
|
}
|
|
93
93
|
const iteration = await ctx.nextIteration();
|
|
94
94
|
if (signal == null ? void 0 : signal.aborted) {
|
|
@@ -98,7 +98,7 @@ var _executeContext = async (props) => {
|
|
|
98
98
|
reason: _nullishCoalesce(signal.reason, () => ( "The operation was aborted"))
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
|
-
return new (0,
|
|
101
|
+
return new (0, _chunkHJKOSEH2cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(signal.reason, () => ( "The operation was aborted")));
|
|
102
102
|
}
|
|
103
103
|
cleanups.push(
|
|
104
104
|
iteration.traces.onPush((traces) => {
|
|
@@ -132,25 +132,25 @@ var _executeContext = async (props) => {
|
|
|
132
132
|
}
|
|
133
133
|
if (iteration.status.type === "exit_success") {
|
|
134
134
|
const exitName = iteration.status.exit_success.exit_name;
|
|
135
|
-
return new (0,
|
|
135
|
+
return new (0, _chunkHJKOSEH2cjs.SuccessExecutionResult)(ctx, {
|
|
136
136
|
exit: iteration.exits.find((x) => x.name === exitName),
|
|
137
137
|
result: iteration.status.exit_success.return_value
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
if (iteration.status.type === "callback_requested") {
|
|
141
|
-
return new (0,
|
|
141
|
+
return new (0, _chunkHJKOSEH2cjs.PartialExecutionResult)(
|
|
142
142
|
ctx,
|
|
143
143
|
iteration.status.callback_requested.signal,
|
|
144
|
-
|
|
144
|
+
_chunkHJKOSEH2cjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
|
|
145
145
|
);
|
|
146
146
|
}
|
|
147
147
|
if (iteration.status.type === "thinking_requested" || iteration.status.type === "exit_error" || iteration.status.type === "execution_error" || iteration.status.type === "invalid_code_error") {
|
|
148
148
|
continue;
|
|
149
149
|
}
|
|
150
|
-
return new (0,
|
|
150
|
+
return new (0, _chunkHJKOSEH2cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)));
|
|
151
151
|
}
|
|
152
152
|
} catch (error) {
|
|
153
|
-
return new (0,
|
|
153
|
+
return new (0, _chunkHJKOSEH2cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
|
|
154
154
|
} finally {
|
|
155
155
|
for (const cleanup of cleanups) {
|
|
156
156
|
try {
|
|
@@ -171,38 +171,33 @@ var executeIteration = async ({
|
|
|
171
171
|
var _a, _b, _c, _d, _e;
|
|
172
172
|
let startedAt = Date.now();
|
|
173
173
|
const traces = iteration.traces;
|
|
174
|
-
const
|
|
174
|
+
const model = await cognitive.getModelDetails(_nullishCoalesce(ctx.model, () => ( "best")));
|
|
175
|
+
const modelLimit = model.input.maxTokens;
|
|
175
176
|
const responseLengthBuffer = getModelOutputLimit(modelLimit);
|
|
176
|
-
const messages =
|
|
177
|
+
const messages = _chunkJGVAZO4Xcjs.truncateWrappedContent.call(void 0, {
|
|
177
178
|
messages: iteration.messages,
|
|
178
179
|
tokenLimit: modelLimit - responseLengthBuffer,
|
|
179
|
-
throwOnFailure:
|
|
180
|
+
throwOnFailure: true
|
|
180
181
|
}).filter(
|
|
181
182
|
(x) => (
|
|
182
183
|
// Filter out empty messages, as they are not valid inputs for the LLM
|
|
183
184
|
// This can happen when a message is truncated and the content is empty
|
|
184
|
-
x.content.trim().length > 0
|
|
185
|
+
typeof x.content !== "string" || x.content.trim().length > 0
|
|
185
186
|
)
|
|
186
187
|
);
|
|
187
188
|
traces.push({
|
|
188
189
|
type: "llm_call_started",
|
|
189
190
|
started_at: startedAt,
|
|
190
191
|
ended_at: startedAt,
|
|
191
|
-
model:
|
|
192
|
+
model: model.ref
|
|
192
193
|
});
|
|
193
194
|
const output = await cognitive.generateContent({
|
|
194
195
|
signal: abortSignal,
|
|
195
196
|
systemPrompt: (_a = messages.find((x) => x.role === "system")) == null ? void 0 : _a.content,
|
|
196
|
-
model:
|
|
197
|
+
model: model.ref,
|
|
197
198
|
temperature: ctx.temperature,
|
|
198
199
|
responseFormat: "text",
|
|
199
|
-
messages: messages.filter((x) => x.role
|
|
200
|
-
(x) => ({
|
|
201
|
-
role: x.role === "user" ? "user" : "assistant",
|
|
202
|
-
type: "text",
|
|
203
|
-
content: x.content
|
|
204
|
-
})
|
|
205
|
-
),
|
|
200
|
+
messages: messages.filter((x) => x.role !== "system"),
|
|
206
201
|
stopSequences: ctx.version.getStopTokens()
|
|
207
202
|
});
|
|
208
203
|
const out = ((_c = (_b = output.output.choices) == null ? void 0 : _b[0]) == null ? void 0 : _c.type) === "text" && typeof ((_d = output.output.choices) == null ? void 0 : _d[0].content) === "string" ? output.output.choices[0].content : null;
|
|
@@ -247,10 +242,10 @@ var executeIteration = async ({
|
|
|
247
242
|
type: "llm_call_success",
|
|
248
243
|
started_at: startedAt,
|
|
249
244
|
ended_at: iteration.llm.ended_at,
|
|
250
|
-
model:
|
|
245
|
+
model: model.ref,
|
|
251
246
|
code: iteration.code
|
|
252
247
|
});
|
|
253
|
-
const vmContext = { ...
|
|
248
|
+
const vmContext = { ..._chunk276Q6EWPcjs.stripInvalidIdentifiers.call(void 0, iteration.variables) };
|
|
254
249
|
for (const obj of iteration.objects) {
|
|
255
250
|
const internalValues = {};
|
|
256
251
|
const instance = {};
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
PartialExecutionResult,
|
|
8
8
|
Snapshot,
|
|
9
9
|
SuccessExecutionResult
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-PRVFVXT4.js";
|
|
11
|
+
import "./chunk-KH6JQYQA.js";
|
|
12
|
+
import "./chunk-JAGB2AOU.js";
|
|
13
|
+
import "./chunk-IH2WQFO5.js";
|
|
14
14
|
import {
|
|
15
15
|
AssignmentError,
|
|
16
16
|
CodeExecutionError,
|
|
@@ -24,16 +24,16 @@ import {
|
|
|
24
24
|
import {
|
|
25
25
|
cleanStackTrace
|
|
26
26
|
} from "./chunk-JQBT7UWN.js";
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-JMSZKB4T.js";
|
|
28
|
+
import "./chunk-GGWM6X2K.js";
|
|
29
29
|
import "./chunk-ORQP26SZ.js";
|
|
30
30
|
import {
|
|
31
31
|
truncateWrappedContent
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-SNDVQU5A.js";
|
|
33
33
|
import {
|
|
34
34
|
init,
|
|
35
35
|
stripInvalidIdentifiers
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-4MNIJGK6.js";
|
|
37
37
|
import {
|
|
38
38
|
clamp_default,
|
|
39
39
|
isEqual_default,
|
|
@@ -71,7 +71,7 @@ var executeContext = async (props) => {
|
|
|
71
71
|
var _executeContext = async (props) => {
|
|
72
72
|
var _a, _b, _c, _d;
|
|
73
73
|
const { signal, onIterationEnd, onTrace, onExit, onBeforeExecution } = props;
|
|
74
|
-
const cognitive = props.client
|
|
74
|
+
const cognitive = Cognitive.isCognitiveClient(props.client) ? props.client : new Cognitive({ client: props.client });
|
|
75
75
|
const cleanups = [];
|
|
76
76
|
const ctx = new Context({
|
|
77
77
|
chat: props.chat,
|
|
@@ -171,38 +171,33 @@ var executeIteration = async ({
|
|
|
171
171
|
var _a, _b, _c, _d, _e;
|
|
172
172
|
let startedAt = Date.now();
|
|
173
173
|
const traces = iteration.traces;
|
|
174
|
-
const
|
|
174
|
+
const model = await cognitive.getModelDetails(ctx.model ?? "best");
|
|
175
|
+
const modelLimit = model.input.maxTokens;
|
|
175
176
|
const responseLengthBuffer = getModelOutputLimit(modelLimit);
|
|
176
177
|
const messages = truncateWrappedContent({
|
|
177
178
|
messages: iteration.messages,
|
|
178
179
|
tokenLimit: modelLimit - responseLengthBuffer,
|
|
179
|
-
throwOnFailure:
|
|
180
|
+
throwOnFailure: true
|
|
180
181
|
}).filter(
|
|
181
182
|
(x) => (
|
|
182
183
|
// Filter out empty messages, as they are not valid inputs for the LLM
|
|
183
184
|
// This can happen when a message is truncated and the content is empty
|
|
184
|
-
x.content.trim().length > 0
|
|
185
|
+
typeof x.content !== "string" || x.content.trim().length > 0
|
|
185
186
|
)
|
|
186
187
|
);
|
|
187
188
|
traces.push({
|
|
188
189
|
type: "llm_call_started",
|
|
189
190
|
started_at: startedAt,
|
|
190
191
|
ended_at: startedAt,
|
|
191
|
-
model:
|
|
192
|
+
model: model.ref
|
|
192
193
|
});
|
|
193
194
|
const output = await cognitive.generateContent({
|
|
194
195
|
signal: abortSignal,
|
|
195
196
|
systemPrompt: (_a = messages.find((x) => x.role === "system")) == null ? void 0 : _a.content,
|
|
196
|
-
model:
|
|
197
|
+
model: model.ref,
|
|
197
198
|
temperature: ctx.temperature,
|
|
198
199
|
responseFormat: "text",
|
|
199
|
-
messages: messages.filter((x) => x.role
|
|
200
|
-
(x) => ({
|
|
201
|
-
role: x.role === "user" ? "user" : "assistant",
|
|
202
|
-
type: "text",
|
|
203
|
-
content: x.content
|
|
204
|
-
})
|
|
205
|
-
),
|
|
200
|
+
messages: messages.filter((x) => x.role !== "system"),
|
|
206
201
|
stopSequences: ctx.version.getStopTokens()
|
|
207
202
|
});
|
|
208
203
|
const out = ((_c = (_b = output.output.choices) == null ? void 0 : _b[0]) == null ? void 0 : _c.type) === "text" && typeof ((_d = output.output.choices) == null ? void 0 : _d[0].content) === "string" ? output.output.choices[0].content : null;
|
|
@@ -247,7 +242,7 @@ var executeIteration = async ({
|
|
|
247
242
|
type: "llm_call_success",
|
|
248
243
|
started_at: startedAt,
|
|
249
244
|
ended_at: iteration.llm.ended_at,
|
|
250
|
-
model:
|
|
245
|
+
model: model.ref,
|
|
251
246
|
code: iteration.code
|
|
252
247
|
});
|
|
253
248
|
const vmContext = { ...stripInvalidIdentifiers(iteration.variables) };
|
package/dist/llmz.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ import { Context, Iteration } from './context.js';
|
|
|
4
4
|
import { Exit, ExitResult } from './exit.js';
|
|
5
5
|
import { ValueOrGetter } from './getter.js';
|
|
6
6
|
import { type ObjectInstance } from './objects.js';
|
|
7
|
+
import { ExecutionResult } from './result.js';
|
|
7
8
|
import { Snapshot } from './snapshots.js';
|
|
8
9
|
import { type Tool } from './tool.js';
|
|
9
10
|
import { Trace } from './types.js';
|
|
10
|
-
import { ExecutionResult } from './result.js';
|
|
11
11
|
export type ExecutionHooks = {
|
|
12
12
|
/**
|
|
13
13
|
* Called after each iteration ends
|