@botpress/runtime 1.3.4 → 1.3.6
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/dist/definition.js +123 -52
- package/dist/definition.js.map +3 -3
- package/dist/internal.js +119 -48
- package/dist/internal.js.map +3 -3
- package/dist/library.js +105 -34
- package/dist/library.js.map +2 -2
- package/dist/runtime/autonomous.d.ts.map +1 -1
- package/dist/runtime/chat/chat.d.ts +161 -3
- package/dist/runtime/chat/chat.d.ts.map +1 -1
- package/dist/runtime/chat/components.d.ts +487 -0
- package/dist/runtime/chat/components.d.ts.map +1 -0
- package/dist/runtime/handlers/conversation.d.ts.map +1 -1
- package/dist/runtime.js +164 -100
- package/dist/runtime.js.map +3 -3
- package/dist/telemetry/spans/index.d.ts +6 -0
- package/dist/telemetry/spans/index.d.ts.map +1 -1
- package/dist/ui.js +6 -0
- package/dist/ui.js.map +2 -2
- package/package.json +1 -1
package/dist/definition.js
CHANGED
|
@@ -48,7 +48,7 @@ var init_define_BUILD = __esm({
|
|
|
48
48
|
var define_PACKAGE_VERSIONS_default;
|
|
49
49
|
var init_define_PACKAGE_VERSIONS = __esm({
|
|
50
50
|
"<define:__PACKAGE_VERSIONS__>"() {
|
|
51
|
-
define_PACKAGE_VERSIONS_default = { runtime: "1.3.
|
|
51
|
+
define_PACKAGE_VERSIONS_default = { runtime: "1.3.6", adk: "not-installed", sdk: "4.17.0", llmz: "0.0.26", zai: "2.1.16", cognitive: "0.1.47" };
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -39302,6 +39302,7 @@ init_define_BUILD();
|
|
|
39302
39302
|
init_define_PACKAGE_VERSIONS();
|
|
39303
39303
|
import {
|
|
39304
39304
|
Chat,
|
|
39305
|
+
DefaultComponents,
|
|
39305
39306
|
isAnyComponent as isAnyComponent2
|
|
39306
39307
|
} from "llmz";
|
|
39307
39308
|
|
|
@@ -39496,9 +39497,6 @@ ${openTag}${inner}${closeTag}
|
|
|
39496
39497
|
\`\`\``;
|
|
39497
39498
|
}
|
|
39498
39499
|
|
|
39499
|
-
// src/runtime/chat/chat.ts
|
|
39500
|
-
import { DefaultComponents } from "llmz";
|
|
39501
|
-
|
|
39502
39500
|
// ../../node_modules/.bun/dedent@1.7.0/node_modules/dedent/dist/dedent.mjs
|
|
39503
39501
|
init_define_BUILD();
|
|
39504
39502
|
init_define_PACKAGE_VERSIONS();
|
|
@@ -39609,25 +39607,6 @@ ${indent}`);
|
|
|
39609
39607
|
return value;
|
|
39610
39608
|
}
|
|
39611
39609
|
|
|
39612
|
-
// src/runtime/config.ts
|
|
39613
|
-
init_define_BUILD();
|
|
39614
|
-
init_define_PACKAGE_VERSIONS();
|
|
39615
|
-
import { limitConfigs } from "@bpinternal/const";
|
|
39616
|
-
var Transcript = {
|
|
39617
|
-
/** How many messages will be preserved in the transcript before summarization */
|
|
39618
|
-
SUMMARY_MAX_MESSAGES: 50,
|
|
39619
|
-
/** How many messages will be preserved at the end of the transcript for higher-precision recall of recent messages */
|
|
39620
|
-
SUMMARY_END_PADDING: 10,
|
|
39621
|
-
/** Max transcript size in bytes before summarization */
|
|
39622
|
-
SUMMARY_MAX_BYTES: limitConfigs.state_item_payload_bytes.value * 0.8,
|
|
39623
|
-
/** Max bytes for a single message in the transcript */
|
|
39624
|
-
TRANSCRIPT_ITEM_MAX_BYTES: 1e4
|
|
39625
|
-
};
|
|
39626
|
-
|
|
39627
|
-
// src/runtime/chat/citations.ts
|
|
39628
|
-
init_define_BUILD();
|
|
39629
|
-
init_define_PACKAGE_VERSIONS();
|
|
39630
|
-
|
|
39631
39610
|
// src/utilities/events.ts
|
|
39632
39611
|
init_define_BUILD();
|
|
39633
39612
|
init_define_PACKAGE_VERSIONS();
|
|
@@ -39770,6 +39749,7 @@ var WellKnownMetadata = {
|
|
|
39770
39749
|
|
|
39771
39750
|
// src/runtime/autonomous.ts
|
|
39772
39751
|
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
39752
|
+
import { AsyncResource } from "node:async_hooks";
|
|
39773
39753
|
var Autonomous;
|
|
39774
39754
|
((Autonomous2) => {
|
|
39775
39755
|
Autonomous2.Tool = LlmzTool;
|
|
@@ -39888,7 +39868,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
39888
39868
|
options.interruption
|
|
39889
39869
|
]);
|
|
39890
39870
|
const llmz_execute = (await import("llmz")).execute;
|
|
39891
|
-
const
|
|
39871
|
+
const asyncResource = new AsyncResource("autonomous.execution");
|
|
39892
39872
|
const getNewIteration = (index) => createSpan(
|
|
39893
39873
|
"autonomous.iteration",
|
|
39894
39874
|
{
|
|
@@ -39946,32 +39926,27 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
39946
39926
|
});
|
|
39947
39927
|
return instructions;
|
|
39948
39928
|
},
|
|
39949
|
-
...
|
|
39950
|
-
|
|
39951
|
-
const
|
|
39952
|
-
const allTools = [...tools ?? []];
|
|
39953
|
-
if (search_knowledge) {
|
|
39954
|
-
allTools.push(search_knowledge);
|
|
39955
|
-
}
|
|
39929
|
+
...props.objects && {
|
|
39930
|
+
objects: async (ctx) => {
|
|
39931
|
+
const objs = await getValue(props.objects, ctx) ?? [];
|
|
39956
39932
|
iterationSpan?.setAttribute(
|
|
39957
|
-
"autonomous.
|
|
39958
|
-
|
|
39933
|
+
"autonomous.objects",
|
|
39934
|
+
objs.map((o) => o.name).join(", ")
|
|
39959
39935
|
);
|
|
39960
|
-
|
|
39961
|
-
|
|
39962
|
-
|
|
39963
|
-
|
|
39964
|
-
return context2.run(originalContext, () => {
|
|
39936
|
+
for (const obj of objs) {
|
|
39937
|
+
obj.tools = obj.tools?.map(
|
|
39938
|
+
(tool) => tool.clone({
|
|
39939
|
+
handler: asyncResource.bind((args, ctx2) => {
|
|
39965
39940
|
let err = null;
|
|
39966
39941
|
const result = span(
|
|
39967
39942
|
"autonomous.tool",
|
|
39968
39943
|
{
|
|
39944
|
+
"autonomous.tool.object": obj.name,
|
|
39969
39945
|
"autonomous.tool.name": tool.name,
|
|
39970
39946
|
"autonomous.tool.input": args
|
|
39971
39947
|
},
|
|
39972
39948
|
async (s) => {
|
|
39973
|
-
|
|
39974
|
-
const value = await tool.execute(args, ctx2).catch((e) => {
|
|
39949
|
+
const value = tool.execute(args, ctx2).catch((e) => {
|
|
39975
39950
|
err = e;
|
|
39976
39951
|
if (err && err?.constructor && err?.constructor?.name && err?.constructor?.name === "ThinkSignal") {
|
|
39977
39952
|
s.setAttributes({
|
|
@@ -40007,25 +39982,92 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
40007
39982
|
throw err;
|
|
40008
39983
|
}
|
|
40009
39984
|
return result;
|
|
40010
|
-
})
|
|
40011
|
-
}
|
|
39985
|
+
})
|
|
39986
|
+
})
|
|
39987
|
+
) ?? [];
|
|
39988
|
+
}
|
|
39989
|
+
return objs;
|
|
39990
|
+
}
|
|
39991
|
+
},
|
|
39992
|
+
...(props.tools || props.knowledge) && {
|
|
39993
|
+
tools: async (ctx) => {
|
|
39994
|
+
const tools = props.tools ? await getValue(props.tools, ctx) : [];
|
|
39995
|
+
const allTools = [...tools ?? []];
|
|
39996
|
+
if (search_knowledge) {
|
|
39997
|
+
allTools.push(search_knowledge);
|
|
39998
|
+
}
|
|
39999
|
+
iterationSpan?.setAttribute(
|
|
40000
|
+
"autonomous.tools",
|
|
40001
|
+
allTools?.map((t) => t.name).join(", ")
|
|
40002
|
+
);
|
|
40003
|
+
return allTools.map(
|
|
40004
|
+
(tool) => tool.clone({
|
|
40005
|
+
handler: asyncResource.bind((args, ctx2) => {
|
|
40006
|
+
let err = null;
|
|
40007
|
+
const result = span(
|
|
40008
|
+
"autonomous.tool",
|
|
40009
|
+
{
|
|
40010
|
+
"autonomous.tool.name": tool.name,
|
|
40011
|
+
"autonomous.tool.input": args
|
|
40012
|
+
},
|
|
40013
|
+
async (s) => {
|
|
40014
|
+
const value = tool.execute(args, ctx2).catch((e) => {
|
|
40015
|
+
err = e;
|
|
40016
|
+
if (err && err?.constructor && err?.constructor?.name && err?.constructor?.name === "ThinkSignal") {
|
|
40017
|
+
s.setAttributes({
|
|
40018
|
+
"autonomous.tool.status": "think"
|
|
40019
|
+
});
|
|
40020
|
+
s.setStatus({
|
|
40021
|
+
code: SpanStatusCode.UNSET,
|
|
40022
|
+
message: "ThinkSignal"
|
|
40023
|
+
});
|
|
40024
|
+
err[HandledErrorProp] = true;
|
|
40025
|
+
throw err;
|
|
40026
|
+
} else {
|
|
40027
|
+
s.setAttributes({
|
|
40028
|
+
"autonomous.tool.status": "error",
|
|
40029
|
+
"autonomous.tool.error": err.message
|
|
40030
|
+
});
|
|
40031
|
+
s.setStatus({
|
|
40032
|
+
code: SpanStatusCode.ERROR,
|
|
40033
|
+
message: err.message
|
|
40034
|
+
});
|
|
40035
|
+
s.recordException(err);
|
|
40036
|
+
throw err;
|
|
40037
|
+
}
|
|
40038
|
+
});
|
|
40039
|
+
s.setAttributes({
|
|
40040
|
+
"autonomous.tool.output": value,
|
|
40041
|
+
"autonomous.tool.status": "success"
|
|
40042
|
+
});
|
|
40043
|
+
return value;
|
|
40044
|
+
}
|
|
40045
|
+
);
|
|
40046
|
+
if (err) {
|
|
40047
|
+
throw err;
|
|
40048
|
+
}
|
|
40049
|
+
return result;
|
|
40050
|
+
})
|
|
40012
40051
|
})
|
|
40013
40052
|
);
|
|
40014
40053
|
}
|
|
40015
40054
|
},
|
|
40016
|
-
...props.objects && { objects: props.objects },
|
|
40017
40055
|
...props.exits && { exits: props.exits },
|
|
40018
40056
|
...joinedSignal && { signal: joinedSignal },
|
|
40019
40057
|
...props.hooks?.onBeforeTool && {
|
|
40020
|
-
onBeforeTool: props.hooks.onBeforeTool
|
|
40058
|
+
onBeforeTool: asyncResource.bind(props.hooks.onBeforeTool)
|
|
40021
40059
|
},
|
|
40022
40060
|
...props.hooks?.onAfterTool && {
|
|
40023
|
-
onAfterTool: props.hooks.onAfterTool
|
|
40061
|
+
onAfterTool: asyncResource.bind(props.hooks.onAfterTool)
|
|
40024
40062
|
},
|
|
40025
40063
|
...props.hooks?.onBeforeExecution && {
|
|
40026
|
-
onBeforeExecution:
|
|
40064
|
+
onBeforeExecution: asyncResource.bind(
|
|
40065
|
+
props.hooks.onBeforeExecution
|
|
40066
|
+
)
|
|
40067
|
+
},
|
|
40068
|
+
...props.hooks?.onExit && {
|
|
40069
|
+
onExit: asyncResource.bind(props.hooks.onExit)
|
|
40027
40070
|
},
|
|
40028
|
-
...props.hooks?.onExit && { onExit: props.hooks.onExit },
|
|
40029
40071
|
onTrace: ({ trace: trace2, iteration }) => {
|
|
40030
40072
|
if (trace2.type === "code_execution") {
|
|
40031
40073
|
} else if (trace2.type === "llm_call_started") {
|
|
@@ -40039,7 +40081,11 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
40039
40081
|
"property.value": trace2.value
|
|
40040
40082
|
});
|
|
40041
40083
|
}
|
|
40042
|
-
props.hooks?.onTrace
|
|
40084
|
+
if (props.hooks?.onTrace) {
|
|
40085
|
+
return asyncResource.runInAsyncScope(
|
|
40086
|
+
() => props.hooks.onTrace({ trace: trace2, iteration })
|
|
40087
|
+
);
|
|
40088
|
+
}
|
|
40043
40089
|
},
|
|
40044
40090
|
onIterationEnd: async (iteration, controller) => {
|
|
40045
40091
|
iterationSpan?.setAttributes({
|
|
@@ -40087,8 +40133,11 @@ ${iteration.status.execution_error.stack}`;
|
|
|
40087
40133
|
});
|
|
40088
40134
|
}
|
|
40089
40135
|
iterationSpan?.end();
|
|
40090
|
-
|
|
40091
|
-
|
|
40136
|
+
if (props.hooks?.onIterationEnd) {
|
|
40137
|
+
return await asyncResource.runInAsyncScope(
|
|
40138
|
+
() => props.hooks.onIterationEnd(iteration, controller)
|
|
40139
|
+
);
|
|
40140
|
+
}
|
|
40092
40141
|
}
|
|
40093
40142
|
});
|
|
40094
40143
|
execSpan.setAttribute(
|
|
@@ -44616,8 +44665,24 @@ var adk = {
|
|
|
44616
44665
|
}
|
|
44617
44666
|
};
|
|
44618
44667
|
|
|
44619
|
-
// src/runtime/
|
|
44620
|
-
|
|
44668
|
+
// src/runtime/config.ts
|
|
44669
|
+
init_define_BUILD();
|
|
44670
|
+
init_define_PACKAGE_VERSIONS();
|
|
44671
|
+
import { limitConfigs } from "@bpinternal/const";
|
|
44672
|
+
var Transcript = {
|
|
44673
|
+
/** How many messages will be preserved in the transcript before summarization */
|
|
44674
|
+
SUMMARY_MAX_MESSAGES: 50,
|
|
44675
|
+
/** How many messages will be preserved at the end of the transcript for higher-precision recall of recent messages */
|
|
44676
|
+
SUMMARY_END_PADDING: 10,
|
|
44677
|
+
/** Max transcript size in bytes before summarization */
|
|
44678
|
+
SUMMARY_MAX_BYTES: limitConfigs.state_item_payload_bytes.value * 0.8,
|
|
44679
|
+
/** Max bytes for a single message in the transcript */
|
|
44680
|
+
TRANSCRIPT_ITEM_MAX_BYTES: 1e4
|
|
44681
|
+
};
|
|
44682
|
+
|
|
44683
|
+
// src/runtime/chat/citations.ts
|
|
44684
|
+
init_define_BUILD();
|
|
44685
|
+
init_define_PACKAGE_VERSIONS();
|
|
44621
44686
|
|
|
44622
44687
|
// src/runtime/handlers/index.ts
|
|
44623
44688
|
init_define_BUILD();
|
|
@@ -45202,6 +45267,12 @@ var AutonomousToolSpan = {
|
|
|
45202
45267
|
name: "autonomous.tool",
|
|
45203
45268
|
importance: "high",
|
|
45204
45269
|
attributes: {
|
|
45270
|
+
"autonomous.tool.object": {
|
|
45271
|
+
type: "string",
|
|
45272
|
+
title: "Object Name",
|
|
45273
|
+
description: "The name of the object being used",
|
|
45274
|
+
required: false
|
|
45275
|
+
},
|
|
45205
45276
|
"autonomous.tool.name": {
|
|
45206
45277
|
type: "string",
|
|
45207
45278
|
title: "Tool Name",
|