@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../src/runtime/chat/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAY,CAAC,EAAE,MAAM,eAAe,CAAC;AAG5C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA8Dq3C,CAAC;oBAA8C,CAAC;;;;;;;;oBAA4Q,CAAC;oBAA8C,CAAC;;;;;;;;;;oBAA+T,CAAC;oBAA8C,CAAC;;;;;;;;;;oBAA8S,CAAC;oBAA8C,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,UAAU,CAAC,CAAC;KACpD;CACF"}
|
|
@@ -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.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
|
|
|
@@ -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(
|
|
@@ -45334,6 +45404,7 @@ init_define_BUILD();
|
|
|
45334
45404
|
init_define_PACKAGE_VERSIONS();
|
|
45335
45405
|
import {
|
|
45336
45406
|
Chat,
|
|
45407
|
+
DefaultComponents,
|
|
45337
45408
|
isAnyComponent as isAnyComponent2
|
|
45338
45409
|
} from "llmz";
|
|
45339
45410
|
|
|
@@ -45663,9 +45734,6 @@ ${openTag}${inner}${closeTag}
|
|
|
45663
45734
|
\`\`\``;
|
|
45664
45735
|
}
|
|
45665
45736
|
|
|
45666
|
-
// src/runtime/chat/chat.ts
|
|
45667
|
-
import { DefaultComponents } from "llmz";
|
|
45668
|
-
|
|
45669
45737
|
// ../../node_modules/.bun/dedent@1.7.0/node_modules/dedent/dist/dedent.mjs
|
|
45670
45738
|
init_define_BUILD();
|
|
45671
45739
|
init_define_PACKAGE_VERSIONS();
|
|
@@ -45803,45 +45871,10 @@ var Config = {
|
|
|
45803
45871
|
Analysis
|
|
45804
45872
|
};
|
|
45805
45873
|
|
|
45806
|
-
// src/runtime/chat/citations.ts
|
|
45807
|
-
init_define_BUILD();
|
|
45808
|
-
init_define_PACKAGE_VERSIONS();
|
|
45809
|
-
function expandCitationsInObject(obj, citationsManager) {
|
|
45810
|
-
if (typeof obj === "string" && obj.trim().length > 0) {
|
|
45811
|
-
let footer = "";
|
|
45812
|
-
const { cleaned } = citationsManager.extractCitations(obj, (citation) => {
|
|
45813
|
-
footer += `${JSON.stringify(citation.source)}
|
|
45814
|
-
`;
|
|
45815
|
-
return "";
|
|
45816
|
-
}) ?? { cleaned: obj };
|
|
45817
|
-
if (footer) {
|
|
45818
|
-
return `${cleaned}
|
|
45819
|
-
|
|
45820
|
-
${footer}`.trim();
|
|
45821
|
-
}
|
|
45822
|
-
return cleaned.trim();
|
|
45823
|
-
}
|
|
45824
|
-
if (Array.isArray(obj)) {
|
|
45825
|
-
return obj.map(
|
|
45826
|
-
(item) => expandCitationsInObject(item, citationsManager)
|
|
45827
|
-
);
|
|
45828
|
-
}
|
|
45829
|
-
if (obj && typeof obj === "object") {
|
|
45830
|
-
const result = {};
|
|
45831
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
45832
|
-
result[key] = expandCitationsInObject(value, citationsManager);
|
|
45833
|
-
}
|
|
45834
|
-
return result;
|
|
45835
|
-
}
|
|
45836
|
-
return obj;
|
|
45837
|
-
}
|
|
45838
|
-
|
|
45839
45874
|
// src/runtime/chat/chat.ts
|
|
45840
|
-
var OutgoingMessages = Object.values(DefaultComponents);
|
|
45841
45875
|
var BotpressChat = class extends Chat {
|
|
45842
45876
|
_transcript;
|
|
45843
45877
|
client;
|
|
45844
|
-
cognitive;
|
|
45845
45878
|
conversation;
|
|
45846
45879
|
botId;
|
|
45847
45880
|
logger;
|
|
@@ -45853,14 +45886,20 @@ var BotpressChat = class extends Chat {
|
|
|
45853
45886
|
handler: async (message) => this.handle(message)
|
|
45854
45887
|
});
|
|
45855
45888
|
this.client = context3.client;
|
|
45856
|
-
this.cognitive = context3.cognitive;
|
|
45857
45889
|
this.conversation = context3.conversation;
|
|
45858
45890
|
this.botId = context3.botId;
|
|
45859
45891
|
this.logger = context3.logger;
|
|
45860
45892
|
this.citations = context3.citations;
|
|
45861
45893
|
}
|
|
45862
45894
|
async getComponents() {
|
|
45863
|
-
return
|
|
45895
|
+
return [
|
|
45896
|
+
DefaultComponents.Text,
|
|
45897
|
+
DefaultComponents.Image,
|
|
45898
|
+
DefaultComponents.File,
|
|
45899
|
+
DefaultComponents.Audio,
|
|
45900
|
+
DefaultComponents.Video,
|
|
45901
|
+
DefaultComponents.Card
|
|
45902
|
+
];
|
|
45864
45903
|
}
|
|
45865
45904
|
async clearTranscript() {
|
|
45866
45905
|
this._transcript = [];
|
|
@@ -45979,12 +46018,18 @@ var BotpressChat = class extends Chat {
|
|
|
45979
46018
|
"message.type": message.type
|
|
45980
46019
|
},
|
|
45981
46020
|
async (s) => {
|
|
46021
|
+
const [payload, citations] = this.citations.removeCitationsFromObject(
|
|
46022
|
+
message.payload
|
|
46023
|
+
);
|
|
45982
46024
|
const { message: created } = await this.client.createMessage({
|
|
45983
46025
|
conversationId: this.conversation.id,
|
|
45984
46026
|
tags: message.tags || {},
|
|
45985
46027
|
userId: this.botId,
|
|
45986
|
-
type: message.type,
|
|
45987
|
-
payload:
|
|
46028
|
+
type: message.type.toLowerCase(),
|
|
46029
|
+
payload: {
|
|
46030
|
+
...payload,
|
|
46031
|
+
metadata: { citations }
|
|
46032
|
+
}
|
|
45988
46033
|
});
|
|
45989
46034
|
s.setAttribute("messageId", created.id);
|
|
45990
46035
|
this._transcript?.push({
|
|
@@ -46018,20 +46063,9 @@ var BotpressChat = class extends Chat {
|
|
|
46018
46063
|
if (isAnyComponent2(msg)) {
|
|
46019
46064
|
await this.handle(msg);
|
|
46020
46065
|
} else if (typeof msg === "string" && msg.trim().length) {
|
|
46021
|
-
|
|
46022
|
-
conversationId: this.conversation.id,
|
|
46023
|
-
tags: {},
|
|
46024
|
-
userId: this.botId,
|
|
46066
|
+
await this.sendMessage({
|
|
46025
46067
|
type: "text",
|
|
46026
|
-
payload: {
|
|
46027
|
-
text: expandCitationsInObject(msg, this.citations)
|
|
46028
|
-
}
|
|
46029
|
-
});
|
|
46030
|
-
this._transcript?.push({
|
|
46031
|
-
id: message2.id,
|
|
46032
|
-
role: "assistant",
|
|
46033
|
-
content: msg.trim(),
|
|
46034
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
46068
|
+
payload: { text: msg }
|
|
46035
46069
|
});
|
|
46036
46070
|
}
|
|
46037
46071
|
}
|
|
@@ -46039,28 +46073,16 @@ var BotpressChat = class extends Chat {
|
|
|
46039
46073
|
}
|
|
46040
46074
|
const components = await this.getComponents();
|
|
46041
46075
|
const component = components.find(
|
|
46042
|
-
(c) => c.definition.name.toLowerCase() === message.type.toLowerCase()
|
|
46076
|
+
(c) => c.definition.name.toLowerCase() === message.type.toLowerCase() || c.definition.aliases?.map((x) => x.toLowerCase()).includes(message.type.toLowerCase())
|
|
46043
46077
|
);
|
|
46044
46078
|
if (!component) {
|
|
46045
46079
|
throw new Error(
|
|
46046
46080
|
`Could not find component for message type "${message.type}"`
|
|
46047
46081
|
);
|
|
46048
46082
|
}
|
|
46049
|
-
|
|
46050
|
-
conversationId: this.conversation.id,
|
|
46051
|
-
tags: {},
|
|
46052
|
-
userId: this.botId,
|
|
46083
|
+
await this.sendMessage({
|
|
46053
46084
|
type: component.definition.name,
|
|
46054
|
-
payload:
|
|
46055
|
-
message.props,
|
|
46056
|
-
this.citations
|
|
46057
|
-
)
|
|
46058
|
-
});
|
|
46059
|
-
this._transcript?.push({
|
|
46060
|
-
id: created.id,
|
|
46061
|
-
role: "assistant",
|
|
46062
|
-
content: JSON.stringify(message, null, 2),
|
|
46063
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
46085
|
+
payload: message.props
|
|
46064
46086
|
});
|
|
46065
46087
|
}
|
|
46066
46088
|
);
|
|
@@ -46139,6 +46161,39 @@ var BotpressChat = class extends Chat {
|
|
|
46139
46161
|
}
|
|
46140
46162
|
};
|
|
46141
46163
|
|
|
46164
|
+
// src/runtime/chat/citations.ts
|
|
46165
|
+
init_define_BUILD();
|
|
46166
|
+
init_define_PACKAGE_VERSIONS();
|
|
46167
|
+
function expandCitationsInObject(obj, citationsManager) {
|
|
46168
|
+
if (typeof obj === "string" && obj.trim().length > 0) {
|
|
46169
|
+
let footer = "";
|
|
46170
|
+
const { cleaned } = citationsManager.extractCitations(obj, (citation) => {
|
|
46171
|
+
footer += `${JSON.stringify(citation.source)}
|
|
46172
|
+
`;
|
|
46173
|
+
return "";
|
|
46174
|
+
}) ?? { cleaned: obj };
|
|
46175
|
+
if (footer) {
|
|
46176
|
+
return `${cleaned}
|
|
46177
|
+
|
|
46178
|
+
${footer}`.trim();
|
|
46179
|
+
}
|
|
46180
|
+
return cleaned.trim();
|
|
46181
|
+
}
|
|
46182
|
+
if (Array.isArray(obj)) {
|
|
46183
|
+
return obj.map(
|
|
46184
|
+
(item) => expandCitationsInObject(item, citationsManager)
|
|
46185
|
+
);
|
|
46186
|
+
}
|
|
46187
|
+
if (obj && typeof obj === "object") {
|
|
46188
|
+
const result = {};
|
|
46189
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
46190
|
+
result[key] = expandCitationsInObject(value, citationsManager);
|
|
46191
|
+
}
|
|
46192
|
+
return result;
|
|
46193
|
+
}
|
|
46194
|
+
return obj;
|
|
46195
|
+
}
|
|
46196
|
+
|
|
46142
46197
|
// src/runtime/chat/transcript.ts
|
|
46143
46198
|
init_define_BUILD();
|
|
46144
46199
|
init_define_PACKAGE_VERSIONS();
|
|
@@ -46202,7 +46257,7 @@ function findMatchingHandler(handlers2, incomingChannel) {
|
|
|
46202
46257
|
var setup = (bot2) => {
|
|
46203
46258
|
bot2.on.message(
|
|
46204
46259
|
"*",
|
|
46205
|
-
async ({ conversation, message, logger,
|
|
46260
|
+
async ({ conversation, message, logger, ctx, event, user: user2 }) => {
|
|
46206
46261
|
await span(
|
|
46207
46262
|
"handler.conversation",
|
|
46208
46263
|
{
|
|
@@ -46220,7 +46275,10 @@ var setup = (bot2) => {
|
|
|
46220
46275
|
},
|
|
46221
46276
|
async () => {
|
|
46222
46277
|
const handlerName = conversation.integration + "." + conversation.channel;
|
|
46223
|
-
const handler = findMatchingHandler(
|
|
46278
|
+
const handler = findMatchingHandler(
|
|
46279
|
+
adk.project.conversations,
|
|
46280
|
+
handlerName
|
|
46281
|
+
);
|
|
46224
46282
|
if (!handler) {
|
|
46225
46283
|
logger.debug(
|
|
46226
46284
|
`Skipping message, no ADK Conversation defined for "${handlerName}"`
|
|
@@ -47124,6 +47182,12 @@ var AutonomousToolSpan = {
|
|
|
47124
47182
|
name: "autonomous.tool",
|
|
47125
47183
|
importance: "high",
|
|
47126
47184
|
attributes: {
|
|
47185
|
+
"autonomous.tool.object": {
|
|
47186
|
+
type: "string",
|
|
47187
|
+
title: "Object Name",
|
|
47188
|
+
description: "The name of the object being used",
|
|
47189
|
+
required: false
|
|
47190
|
+
},
|
|
47127
47191
|
"autonomous.tool.name": {
|
|
47128
47192
|
type: "string",
|
|
47129
47193
|
title: "Tool Name",
|