@botpress/runtime 1.3.3 → 1.3.5
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 +104 -28
- package/dist/definition.js.map +2 -2
- package/dist/internal.js +104 -28
- package/dist/internal.js.map +2 -2
- package/dist/library.js +104 -28
- package/dist/library.js.map +2 -2
- package/dist/runtime/autonomous.d.ts.map +1 -1
- package/dist/runtime/handlers/conversation.d.ts.map +1 -1
- package/dist/runtime.js +109 -30
- package/dist/runtime.js.map +2 -2
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autonomous.d.ts","sourceRoot":"","sources":["../../src/runtime/autonomous.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAEL,KAAK,IAAI,IAAI,QAAQ,EACrB,KAAK,aAAa,EAClB,KAAK,OAAO,IAAI,WAAW,EAC5B,MAAM,MAAM,CAAC;AACd,OAAO,EACL,SAAS,IAAI,aAAa,EAC1B,IAAI,IAAI,QAAQ,EAChB,MAAM,IAAI,OAAO,EACjB,WAAW,IAAI,YAAY,EAC3B,cAAc,IAAI,eAAe,EACjC,QAAQ,IAAI,SAAS,EACrB,gBAAgB,IAAI,iBAAiB,EAItC,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,KAAK,UAAU,IAAI,cAAc,EAAE,MAAM,MAAM,CAAC;AAC3E,OAAO,EAAE,cAAc,IAAI,UAAU,EAAE,MAAM,MAAM,CAAC;AAUpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
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,CAAC,EAAE,aAAa,EAAE,CAAC;QAC5B,4DAA4D;QAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IAEF,KAAY,SAAS,GAAG,CACtB,KAAK,EAAE,UAAU,CAAC,KAAK,KACpB,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAEvC,KAAY,cAAc,GAAG;QAC3B,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;QACxB,YAAY,CAAC,EAAE,WAAW,CAAC;QAC3B,YAAY,EAAE,KAAK,GAAG,KAAK,EAAE,CAAC;KAC/B,CAAC;CAmhBH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/runtime/handlers/conversation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/runtime/handlers/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAS/E,eAAO,MAAM,KAAK,GAAI,KAAK,iBAAiB,SA2D3C,CAAC"}
|
package/dist/runtime.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.5", 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
|
|
|
@@ -39723,6 +39723,7 @@ var WellKnownMetadata = {
|
|
|
39723
39723
|
|
|
39724
39724
|
// src/runtime/autonomous.ts
|
|
39725
39725
|
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
39726
|
+
import { AsyncResource } from "node:async_hooks";
|
|
39726
39727
|
var Autonomous;
|
|
39727
39728
|
((Autonomous2) => {
|
|
39728
39729
|
Autonomous2.Tool = LlmzTool;
|
|
@@ -39841,7 +39842,7 @@ If the question is not related to the knowledge bases, do NOT use this tool.`.tr
|
|
|
39841
39842
|
options.interruption
|
|
39842
39843
|
]);
|
|
39843
39844
|
const llmz_execute = (await import("llmz")).execute;
|
|
39844
|
-
const
|
|
39845
|
+
const asyncResource = new AsyncResource("autonomous.execution");
|
|
39845
39846
|
const getNewIteration = (index) => createSpan(
|
|
39846
39847
|
"autonomous.iteration",
|
|
39847
39848
|
{
|
|
@@ -39899,32 +39900,27 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
39899
39900
|
});
|
|
39900
39901
|
return instructions;
|
|
39901
39902
|
},
|
|
39902
|
-
...
|
|
39903
|
-
|
|
39904
|
-
const
|
|
39905
|
-
const allTools = [...tools ?? []];
|
|
39906
|
-
if (search_knowledge) {
|
|
39907
|
-
allTools.push(search_knowledge);
|
|
39908
|
-
}
|
|
39903
|
+
...props.objects && {
|
|
39904
|
+
objects: async (ctx) => {
|
|
39905
|
+
const objs = await getValue(props.objects, ctx) ?? [];
|
|
39909
39906
|
iterationSpan?.setAttribute(
|
|
39910
|
-
"autonomous.
|
|
39911
|
-
|
|
39907
|
+
"autonomous.objects",
|
|
39908
|
+
objs.map((o) => o.name).join(", ")
|
|
39912
39909
|
);
|
|
39913
|
-
|
|
39914
|
-
|
|
39915
|
-
|
|
39916
|
-
|
|
39917
|
-
return context2.run(originalContext, () => {
|
|
39910
|
+
for (const obj of objs) {
|
|
39911
|
+
obj.tools = obj.tools?.map(
|
|
39912
|
+
(tool) => tool.clone({
|
|
39913
|
+
handler: asyncResource.bind((args, ctx2) => {
|
|
39918
39914
|
let err = null;
|
|
39919
39915
|
const result = span(
|
|
39920
39916
|
"autonomous.tool",
|
|
39921
39917
|
{
|
|
39918
|
+
"autonomous.tool.object": obj.name,
|
|
39922
39919
|
"autonomous.tool.name": tool.name,
|
|
39923
39920
|
"autonomous.tool.input": args
|
|
39924
39921
|
},
|
|
39925
39922
|
async (s) => {
|
|
39926
|
-
|
|
39927
|
-
const value = await tool.execute(args, ctx2).catch((e) => {
|
|
39923
|
+
const value = tool.execute(args, ctx2).catch((e) => {
|
|
39928
39924
|
err = e;
|
|
39929
39925
|
if (err && err?.constructor && err?.constructor?.name && err?.constructor?.name === "ThinkSignal") {
|
|
39930
39926
|
s.setAttributes({
|
|
@@ -39960,25 +39956,92 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
39960
39956
|
throw err;
|
|
39961
39957
|
}
|
|
39962
39958
|
return result;
|
|
39963
|
-
})
|
|
39964
|
-
}
|
|
39959
|
+
})
|
|
39960
|
+
})
|
|
39961
|
+
) ?? [];
|
|
39962
|
+
}
|
|
39963
|
+
return objs;
|
|
39964
|
+
}
|
|
39965
|
+
},
|
|
39966
|
+
...(props.tools || props.knowledge) && {
|
|
39967
|
+
tools: async (ctx) => {
|
|
39968
|
+
const tools = props.tools ? await getValue(props.tools, ctx) : [];
|
|
39969
|
+
const allTools = [...tools ?? []];
|
|
39970
|
+
if (search_knowledge) {
|
|
39971
|
+
allTools.push(search_knowledge);
|
|
39972
|
+
}
|
|
39973
|
+
iterationSpan?.setAttribute(
|
|
39974
|
+
"autonomous.tools",
|
|
39975
|
+
allTools?.map((t) => t.name).join(", ")
|
|
39976
|
+
);
|
|
39977
|
+
return allTools.map(
|
|
39978
|
+
(tool) => tool.clone({
|
|
39979
|
+
handler: asyncResource.bind((args, ctx2) => {
|
|
39980
|
+
let err = null;
|
|
39981
|
+
const result = span(
|
|
39982
|
+
"autonomous.tool",
|
|
39983
|
+
{
|
|
39984
|
+
"autonomous.tool.name": tool.name,
|
|
39985
|
+
"autonomous.tool.input": args
|
|
39986
|
+
},
|
|
39987
|
+
async (s) => {
|
|
39988
|
+
const value = tool.execute(args, ctx2).catch((e) => {
|
|
39989
|
+
err = e;
|
|
39990
|
+
if (err && err?.constructor && err?.constructor?.name && err?.constructor?.name === "ThinkSignal") {
|
|
39991
|
+
s.setAttributes({
|
|
39992
|
+
"autonomous.tool.status": "think"
|
|
39993
|
+
});
|
|
39994
|
+
s.setStatus({
|
|
39995
|
+
code: SpanStatusCode.UNSET,
|
|
39996
|
+
message: "ThinkSignal"
|
|
39997
|
+
});
|
|
39998
|
+
err[HandledErrorProp] = true;
|
|
39999
|
+
throw err;
|
|
40000
|
+
} else {
|
|
40001
|
+
s.setAttributes({
|
|
40002
|
+
"autonomous.tool.status": "error",
|
|
40003
|
+
"autonomous.tool.error": err.message
|
|
40004
|
+
});
|
|
40005
|
+
s.setStatus({
|
|
40006
|
+
code: SpanStatusCode.ERROR,
|
|
40007
|
+
message: err.message
|
|
40008
|
+
});
|
|
40009
|
+
s.recordException(err);
|
|
40010
|
+
throw err;
|
|
40011
|
+
}
|
|
40012
|
+
});
|
|
40013
|
+
s.setAttributes({
|
|
40014
|
+
"autonomous.tool.output": value,
|
|
40015
|
+
"autonomous.tool.status": "success"
|
|
40016
|
+
});
|
|
40017
|
+
return value;
|
|
40018
|
+
}
|
|
40019
|
+
);
|
|
40020
|
+
if (err) {
|
|
40021
|
+
throw err;
|
|
40022
|
+
}
|
|
40023
|
+
return result;
|
|
40024
|
+
})
|
|
39965
40025
|
})
|
|
39966
40026
|
);
|
|
39967
40027
|
}
|
|
39968
40028
|
},
|
|
39969
|
-
...props.objects && { objects: props.objects },
|
|
39970
40029
|
...props.exits && { exits: props.exits },
|
|
39971
40030
|
...joinedSignal && { signal: joinedSignal },
|
|
39972
40031
|
...props.hooks?.onBeforeTool && {
|
|
39973
|
-
onBeforeTool: props.hooks.onBeforeTool
|
|
40032
|
+
onBeforeTool: asyncResource.bind(props.hooks.onBeforeTool)
|
|
39974
40033
|
},
|
|
39975
40034
|
...props.hooks?.onAfterTool && {
|
|
39976
|
-
onAfterTool: props.hooks.onAfterTool
|
|
40035
|
+
onAfterTool: asyncResource.bind(props.hooks.onAfterTool)
|
|
39977
40036
|
},
|
|
39978
40037
|
...props.hooks?.onBeforeExecution && {
|
|
39979
|
-
onBeforeExecution:
|
|
40038
|
+
onBeforeExecution: asyncResource.bind(
|
|
40039
|
+
props.hooks.onBeforeExecution
|
|
40040
|
+
)
|
|
40041
|
+
},
|
|
40042
|
+
...props.hooks?.onExit && {
|
|
40043
|
+
onExit: asyncResource.bind(props.hooks.onExit)
|
|
39980
40044
|
},
|
|
39981
|
-
...props.hooks?.onExit && { onExit: props.hooks.onExit },
|
|
39982
40045
|
onTrace: ({ trace: trace2, iteration }) => {
|
|
39983
40046
|
if (trace2.type === "code_execution") {
|
|
39984
40047
|
} else if (trace2.type === "llm_call_started") {
|
|
@@ -39992,7 +40055,11 @@ Always prefer information from the knowledge bases over general knowledge when a
|
|
|
39992
40055
|
"property.value": trace2.value
|
|
39993
40056
|
});
|
|
39994
40057
|
}
|
|
39995
|
-
props.hooks?.onTrace
|
|
40058
|
+
if (props.hooks?.onTrace) {
|
|
40059
|
+
return asyncResource.runInAsyncScope(
|
|
40060
|
+
() => props.hooks.onTrace({ trace: trace2, iteration })
|
|
40061
|
+
);
|
|
40062
|
+
}
|
|
39996
40063
|
},
|
|
39997
40064
|
onIterationEnd: async (iteration, controller) => {
|
|
39998
40065
|
iterationSpan?.setAttributes({
|
|
@@ -40040,8 +40107,11 @@ ${iteration.status.execution_error.stack}`;
|
|
|
40040
40107
|
});
|
|
40041
40108
|
}
|
|
40042
40109
|
iterationSpan?.end();
|
|
40043
|
-
|
|
40044
|
-
|
|
40110
|
+
if (props.hooks?.onIterationEnd) {
|
|
40111
|
+
return await asyncResource.runInAsyncScope(
|
|
40112
|
+
() => props.hooks.onIterationEnd(iteration, controller)
|
|
40113
|
+
);
|
|
40114
|
+
}
|
|
40045
40115
|
}
|
|
40046
40116
|
});
|
|
40047
40117
|
execSpan.setAttribute(
|
|
@@ -46202,7 +46272,7 @@ function findMatchingHandler(handlers2, incomingChannel) {
|
|
|
46202
46272
|
var setup = (bot2) => {
|
|
46203
46273
|
bot2.on.message(
|
|
46204
46274
|
"*",
|
|
46205
|
-
async ({ conversation, message, logger,
|
|
46275
|
+
async ({ conversation, message, logger, ctx, event, user: user2 }) => {
|
|
46206
46276
|
await span(
|
|
46207
46277
|
"handler.conversation",
|
|
46208
46278
|
{
|
|
@@ -46220,7 +46290,10 @@ var setup = (bot2) => {
|
|
|
46220
46290
|
},
|
|
46221
46291
|
async () => {
|
|
46222
46292
|
const handlerName = conversation.integration + "." + conversation.channel;
|
|
46223
|
-
const handler = findMatchingHandler(
|
|
46293
|
+
const handler = findMatchingHandler(
|
|
46294
|
+
adk.project.conversations,
|
|
46295
|
+
handlerName
|
|
46296
|
+
);
|
|
46224
46297
|
if (!handler) {
|
|
46225
46298
|
logger.debug(
|
|
46226
46299
|
`Skipping message, no ADK Conversation defined for "${handlerName}"`
|
|
@@ -47124,6 +47197,12 @@ var AutonomousToolSpan = {
|
|
|
47124
47197
|
name: "autonomous.tool",
|
|
47125
47198
|
importance: "high",
|
|
47126
47199
|
attributes: {
|
|
47200
|
+
"autonomous.tool.object": {
|
|
47201
|
+
type: "string",
|
|
47202
|
+
title: "Object Name",
|
|
47203
|
+
description: "The name of the object being used",
|
|
47204
|
+
required: false
|
|
47205
|
+
},
|
|
47127
47206
|
"autonomous.tool.name": {
|
|
47128
47207
|
type: "string",
|
|
47129
47208
|
title: "Tool Name",
|