@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/internal.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
|
|
|
@@ -36085,6 +36085,12 @@ var AutonomousToolSpan = {
|
|
|
36085
36085
|
name: "autonomous.tool",
|
|
36086
36086
|
importance: "high",
|
|
36087
36087
|
attributes: {
|
|
36088
|
+
"autonomous.tool.object": {
|
|
36089
|
+
type: "string",
|
|
36090
|
+
title: "Object Name",
|
|
36091
|
+
description: "The name of the object being used",
|
|
36092
|
+
required: false
|
|
36093
|
+
},
|
|
36088
36094
|
"autonomous.tool.name": {
|
|
36089
36095
|
type: "string",
|
|
36090
36096
|
title: "Tool Name",
|
|
@@ -40446,6 +40452,7 @@ var WellKnownMetadata = {
|
|
|
40446
40452
|
|
|
40447
40453
|
// src/runtime/autonomous.ts
|
|
40448
40454
|
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
40455
|
+
import { AsyncResource } from "node:async_hooks";
|
|
40449
40456
|
var Autonomous;
|
|
40450
40457
|
((Autonomous2) => {
|
|
40451
40458
|
Autonomous2.Tool = LlmzTool;
|
|
@@ -40564,7 +40571,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
40564
40571
|
options.interruption
|
|
40565
40572
|
]);
|
|
40566
40573
|
const llmz_execute = (await import("llmz")).execute;
|
|
40567
|
-
const
|
|
40574
|
+
const asyncResource = new AsyncResource("autonomous.execution");
|
|
40568
40575
|
const getNewIteration = (index) => createSpan(
|
|
40569
40576
|
"autonomous.iteration",
|
|
40570
40577
|
{
|
|
@@ -40622,32 +40629,27 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
40622
40629
|
});
|
|
40623
40630
|
return instructions;
|
|
40624
40631
|
},
|
|
40625
|
-
...
|
|
40626
|
-
|
|
40627
|
-
const
|
|
40628
|
-
const allTools = [...tools ?? []];
|
|
40629
|
-
if (search_knowledge) {
|
|
40630
|
-
allTools.push(search_knowledge);
|
|
40631
|
-
}
|
|
40632
|
+
...props.objects && {
|
|
40633
|
+
objects: async (ctx) => {
|
|
40634
|
+
const objs = await getValue(props.objects, ctx) ?? [];
|
|
40632
40635
|
iterationSpan?.setAttribute(
|
|
40633
|
-
"autonomous.
|
|
40634
|
-
|
|
40636
|
+
"autonomous.objects",
|
|
40637
|
+
objs.map((o) => o.name).join(", ")
|
|
40635
40638
|
);
|
|
40636
|
-
|
|
40637
|
-
|
|
40638
|
-
|
|
40639
|
-
|
|
40640
|
-
return context.run(originalContext, () => {
|
|
40639
|
+
for (const obj of objs) {
|
|
40640
|
+
obj.tools = obj.tools?.map(
|
|
40641
|
+
(tool) => tool.clone({
|
|
40642
|
+
handler: asyncResource.bind((args, ctx2) => {
|
|
40641
40643
|
let err = null;
|
|
40642
40644
|
const result = span(
|
|
40643
40645
|
"autonomous.tool",
|
|
40644
40646
|
{
|
|
40647
|
+
"autonomous.tool.object": obj.name,
|
|
40645
40648
|
"autonomous.tool.name": tool.name,
|
|
40646
40649
|
"autonomous.tool.input": args
|
|
40647
40650
|
},
|
|
40648
40651
|
async (s) => {
|
|
40649
|
-
|
|
40650
|
-
const value = await tool.execute(args, ctx2).catch((e) => {
|
|
40652
|
+
const value = tool.execute(args, ctx2).catch((e) => {
|
|
40651
40653
|
err = e;
|
|
40652
40654
|
if (err && err?.constructor && err?.constructor?.name && err?.constructor?.name === "ThinkSignal") {
|
|
40653
40655
|
s.setAttributes({
|
|
@@ -40683,25 +40685,92 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
40683
40685
|
throw err;
|
|
40684
40686
|
}
|
|
40685
40687
|
return result;
|
|
40686
|
-
})
|
|
40687
|
-
}
|
|
40688
|
+
})
|
|
40689
|
+
})
|
|
40690
|
+
) ?? [];
|
|
40691
|
+
}
|
|
40692
|
+
return objs;
|
|
40693
|
+
}
|
|
40694
|
+
},
|
|
40695
|
+
...(props.tools || props.knowledge) && {
|
|
40696
|
+
tools: async (ctx) => {
|
|
40697
|
+
const tools = props.tools ? await getValue(props.tools, ctx) : [];
|
|
40698
|
+
const allTools = [...tools ?? []];
|
|
40699
|
+
if (search_knowledge) {
|
|
40700
|
+
allTools.push(search_knowledge);
|
|
40701
|
+
}
|
|
40702
|
+
iterationSpan?.setAttribute(
|
|
40703
|
+
"autonomous.tools",
|
|
40704
|
+
allTools?.map((t) => t.name).join(", ")
|
|
40705
|
+
);
|
|
40706
|
+
return allTools.map(
|
|
40707
|
+
(tool) => tool.clone({
|
|
40708
|
+
handler: asyncResource.bind((args, ctx2) => {
|
|
40709
|
+
let err = null;
|
|
40710
|
+
const result = span(
|
|
40711
|
+
"autonomous.tool",
|
|
40712
|
+
{
|
|
40713
|
+
"autonomous.tool.name": tool.name,
|
|
40714
|
+
"autonomous.tool.input": args
|
|
40715
|
+
},
|
|
40716
|
+
async (s) => {
|
|
40717
|
+
const value = tool.execute(args, ctx2).catch((e) => {
|
|
40718
|
+
err = e;
|
|
40719
|
+
if (err && err?.constructor && err?.constructor?.name && err?.constructor?.name === "ThinkSignal") {
|
|
40720
|
+
s.setAttributes({
|
|
40721
|
+
"autonomous.tool.status": "think"
|
|
40722
|
+
});
|
|
40723
|
+
s.setStatus({
|
|
40724
|
+
code: SpanStatusCode.UNSET,
|
|
40725
|
+
message: "ThinkSignal"
|
|
40726
|
+
});
|
|
40727
|
+
err[HandledErrorProp] = true;
|
|
40728
|
+
throw err;
|
|
40729
|
+
} else {
|
|
40730
|
+
s.setAttributes({
|
|
40731
|
+
"autonomous.tool.status": "error",
|
|
40732
|
+
"autonomous.tool.error": err.message
|
|
40733
|
+
});
|
|
40734
|
+
s.setStatus({
|
|
40735
|
+
code: SpanStatusCode.ERROR,
|
|
40736
|
+
message: err.message
|
|
40737
|
+
});
|
|
40738
|
+
s.recordException(err);
|
|
40739
|
+
throw err;
|
|
40740
|
+
}
|
|
40741
|
+
});
|
|
40742
|
+
s.setAttributes({
|
|
40743
|
+
"autonomous.tool.output": value,
|
|
40744
|
+
"autonomous.tool.status": "success"
|
|
40745
|
+
});
|
|
40746
|
+
return value;
|
|
40747
|
+
}
|
|
40748
|
+
);
|
|
40749
|
+
if (err) {
|
|
40750
|
+
throw err;
|
|
40751
|
+
}
|
|
40752
|
+
return result;
|
|
40753
|
+
})
|
|
40688
40754
|
})
|
|
40689
40755
|
);
|
|
40690
40756
|
}
|
|
40691
40757
|
},
|
|
40692
|
-
...props.objects && { objects: props.objects },
|
|
40693
40758
|
...props.exits && { exits: props.exits },
|
|
40694
40759
|
...joinedSignal && { signal: joinedSignal },
|
|
40695
40760
|
...props.hooks?.onBeforeTool && {
|
|
40696
|
-
onBeforeTool: props.hooks.onBeforeTool
|
|
40761
|
+
onBeforeTool: asyncResource.bind(props.hooks.onBeforeTool)
|
|
40697
40762
|
},
|
|
40698
40763
|
...props.hooks?.onAfterTool && {
|
|
40699
|
-
onAfterTool: props.hooks.onAfterTool
|
|
40764
|
+
onAfterTool: asyncResource.bind(props.hooks.onAfterTool)
|
|
40700
40765
|
},
|
|
40701
40766
|
...props.hooks?.onBeforeExecution && {
|
|
40702
|
-
onBeforeExecution:
|
|
40767
|
+
onBeforeExecution: asyncResource.bind(
|
|
40768
|
+
props.hooks.onBeforeExecution
|
|
40769
|
+
)
|
|
40770
|
+
},
|
|
40771
|
+
...props.hooks?.onExit && {
|
|
40772
|
+
onExit: asyncResource.bind(props.hooks.onExit)
|
|
40703
40773
|
},
|
|
40704
|
-
...props.hooks?.onExit && { onExit: props.hooks.onExit },
|
|
40705
40774
|
onTrace: ({ trace: trace2, iteration }) => {
|
|
40706
40775
|
if (trace2.type === "code_execution") {
|
|
40707
40776
|
} else if (trace2.type === "llm_call_started") {
|
|
@@ -40715,7 +40784,11 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
40715
40784
|
"property.value": trace2.value
|
|
40716
40785
|
});
|
|
40717
40786
|
}
|
|
40718
|
-
props.hooks?.onTrace
|
|
40787
|
+
if (props.hooks?.onTrace) {
|
|
40788
|
+
return asyncResource.runInAsyncScope(
|
|
40789
|
+
() => props.hooks.onTrace({ trace: trace2, iteration })
|
|
40790
|
+
);
|
|
40791
|
+
}
|
|
40719
40792
|
},
|
|
40720
40793
|
onIterationEnd: async (iteration, controller) => {
|
|
40721
40794
|
iterationSpan?.setAttributes({
|
|
@@ -40763,8 +40836,11 @@ ${iteration.status.execution_error.stack}`;
|
|
|
40763
40836
|
});
|
|
40764
40837
|
}
|
|
40765
40838
|
iterationSpan?.end();
|
|
40766
|
-
|
|
40767
|
-
|
|
40839
|
+
if (props.hooks?.onIterationEnd) {
|
|
40840
|
+
return await asyncResource.runInAsyncScope(
|
|
40841
|
+
() => props.hooks.onIterationEnd(iteration, controller)
|
|
40842
|
+
);
|
|
40843
|
+
}
|
|
40768
40844
|
}
|
|
40769
40845
|
});
|
|
40770
40846
|
execSpan.setAttribute(
|
|
@@ -41903,6 +41979,7 @@ init_define_BUILD();
|
|
|
41903
41979
|
init_define_PACKAGE_VERSIONS();
|
|
41904
41980
|
import {
|
|
41905
41981
|
Chat,
|
|
41982
|
+
DefaultComponents,
|
|
41906
41983
|
isAnyComponent as isAnyComponent2
|
|
41907
41984
|
} from "llmz";
|
|
41908
41985
|
|
|
@@ -42097,9 +42174,6 @@ ${openTag}${inner}${closeTag}
|
|
|
42097
42174
|
\`\`\``;
|
|
42098
42175
|
}
|
|
42099
42176
|
|
|
42100
|
-
// src/runtime/chat/chat.ts
|
|
42101
|
-
import { DefaultComponents } from "llmz";
|
|
42102
|
-
|
|
42103
42177
|
// ../../node_modules/.bun/dedent@1.7.0/node_modules/dedent/dist/dedent.mjs
|
|
42104
42178
|
init_define_BUILD();
|
|
42105
42179
|
init_define_PACKAGE_VERSIONS();
|
|
@@ -42210,6 +42284,20 @@ ${indent}`);
|
|
|
42210
42284
|
return value;
|
|
42211
42285
|
}
|
|
42212
42286
|
|
|
42287
|
+
// src/utilities/events.ts
|
|
42288
|
+
init_define_BUILD();
|
|
42289
|
+
init_define_PACKAGE_VERSIONS();
|
|
42290
|
+
function isEvent(event) {
|
|
42291
|
+
return event !== null && typeof event === "object" && "type" in event && "payload" in event && "id" in event;
|
|
42292
|
+
}
|
|
42293
|
+
function isEventMessage(event) {
|
|
42294
|
+
const type = event?.type || null;
|
|
42295
|
+
if (type === "message_created" && event.payload && typeof event.payload.message === "object") {
|
|
42296
|
+
return true;
|
|
42297
|
+
}
|
|
42298
|
+
return false;
|
|
42299
|
+
}
|
|
42300
|
+
|
|
42213
42301
|
// src/runtime/config.ts
|
|
42214
42302
|
init_define_BUILD();
|
|
42215
42303
|
init_define_PACKAGE_VERSIONS();
|
|
@@ -42229,23 +42317,6 @@ var Transcript = {
|
|
|
42229
42317
|
init_define_BUILD();
|
|
42230
42318
|
init_define_PACKAGE_VERSIONS();
|
|
42231
42319
|
|
|
42232
|
-
// src/utilities/events.ts
|
|
42233
|
-
init_define_BUILD();
|
|
42234
|
-
init_define_PACKAGE_VERSIONS();
|
|
42235
|
-
function isEvent(event) {
|
|
42236
|
-
return event !== null && typeof event === "object" && "type" in event && "payload" in event && "id" in event;
|
|
42237
|
-
}
|
|
42238
|
-
function isEventMessage(event) {
|
|
42239
|
-
const type = event?.type || null;
|
|
42240
|
-
if (type === "message_created" && event.payload && typeof event.payload.message === "object") {
|
|
42241
|
-
return true;
|
|
42242
|
-
}
|
|
42243
|
-
return false;
|
|
42244
|
-
}
|
|
42245
|
-
|
|
42246
|
-
// src/runtime/chat/chat.ts
|
|
42247
|
-
var OutgoingMessages = Object.values(DefaultComponents);
|
|
42248
|
-
|
|
42249
42320
|
// src/runtime/chat/transcript.ts
|
|
42250
42321
|
init_define_BUILD();
|
|
42251
42322
|
init_define_PACKAGE_VERSIONS();
|