@botpress/runtime 1.14.0 → 1.14.1
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 +154 -16
- package/dist/definition.js.map +4 -4
- package/dist/internal.js +159 -19
- package/dist/internal.js.map +4 -4
- package/dist/library.js +156 -18
- package/dist/library.js.map +4 -4
- package/dist/primitives/date-serialization.d.ts +35 -0
- package/dist/primitives/date-serialization.d.ts.map +1 -0
- package/dist/primitives/workflow-cancellation-monitor.d.ts.map +1 -1
- package/dist/primitives/workflow-instance.d.ts +2 -0
- package/dist/primitives/workflow-instance.d.ts.map +1 -1
- package/dist/primitives/workflow-step.d.ts.map +1 -1
- package/dist/runtime.js +154 -16
- package/dist/runtime.js.map +4 -4
- package/dist/telemetry/instrument-http.d.ts.map +1 -1
- package/dist/telemetry/spans/index.d.ts +12 -0
- package/dist/telemetry/spans/index.d.ts.map +1 -1
- package/dist/telemetry/tracing.d.ts +4 -0
- package/dist/telemetry/tracing.d.ts.map +1 -1
- package/dist/ui.js +5 -1
- package/dist/ui.js.map +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep date serialization utilities for workflow step data.
|
|
3
|
+
*
|
|
4
|
+
* When workflow step data is persisted, Date objects must be serialized to a format
|
|
5
|
+
* that can be stored in JSON and later deserialized back to Date objects.
|
|
6
|
+
*
|
|
7
|
+
* This uses a special marker format: { __date__: ISO8601_STRING }
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Deeply serialize Date objects in the input data structure.
|
|
11
|
+
* Date objects are converted to { __date__: ISO8601_STRING } markers.
|
|
12
|
+
*
|
|
13
|
+
* @param data - The data to serialize
|
|
14
|
+
* @returns The serialized data with Date objects converted to markers
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const data = { timestamp: new Date('2024-01-01'), nested: { date: new Date() } }
|
|
18
|
+
* const serialized = serializeDates(data)
|
|
19
|
+
* // { timestamp: { __date__: '2024-01-01T00:00:00.000Z' }, nested: { date: { __date__: '...' } } }
|
|
20
|
+
*/
|
|
21
|
+
export declare function serializeDates<T>(data: T): T;
|
|
22
|
+
/**
|
|
23
|
+
* Deeply deserialize Date objects from the input data structure.
|
|
24
|
+
* Converts { __date__: ISO8601_STRING } markers back to Date objects.
|
|
25
|
+
*
|
|
26
|
+
* @param data - The data to deserialize
|
|
27
|
+
* @returns The deserialized data with markers converted back to Date objects
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const serialized = { timestamp: { __date__: '2024-01-01T00:00:00.000Z' } }
|
|
31
|
+
* const deserialized = deserializeDates(serialized)
|
|
32
|
+
* // { timestamp: Date('2024-01-01T00:00:00.000Z') }
|
|
33
|
+
*/
|
|
34
|
+
export declare function deserializeDates<T>(data: T): T;
|
|
35
|
+
//# sourceMappingURL=date-serialization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-serialization.d.ts","sourceRoot":"","sources":["../../src/primitives/date-serialization.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAqBH;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CA2B5C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CA2B9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-cancellation-monitor.d.ts","sourceRoot":"","sources":["../../src/primitives/workflow-cancellation-monitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"workflow-cancellation-monitor.d.ts","sourceRoot":"","sources":["../../src/primitives/workflow-cancellation-monitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AAGxE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,gCAAgC,CAAC,KAAK,EAAE;IACtD,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,sBAAsB,EAAE,sBAAsB,CAAA;IAC9C,WAAW,EAAE,WAAW,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,GAAG,MAAM,IAAI,CAiDb"}
|
|
@@ -7,9 +7,11 @@ import { TrackedState } from '../runtime/index';
|
|
|
7
7
|
export type WorkflowStepContext = {
|
|
8
8
|
output?: unknown;
|
|
9
9
|
attempts: number;
|
|
10
|
+
maxAttempts?: number;
|
|
10
11
|
startedAt: string;
|
|
11
12
|
finishedAt?: string;
|
|
12
13
|
steps?: Record<string, WorkflowStepContext>;
|
|
14
|
+
mapTotal?: number;
|
|
13
15
|
error?: {
|
|
14
16
|
message: string;
|
|
15
17
|
failedAt: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-instance.d.ts","sourceRoot":"","sources":["../../src/primitives/workflow-instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAGlD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAG1E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAEL,YAAY,EAKb,MAAM,kBAAkB,CAAA;AAOzB,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,CAAC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AAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAU7B;;;;;;;;;;;;;;;;OAgBG;IACH,UAAU,CAAC,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BnE;;;;;;;;;OASG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK;IAU3B;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC,GAAG,KAAK;IAU/C;;;;;;;;;OASG;IACG,OAAO,CAAC,QAAQ,SAAS,MAAM,mBAAmB,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,GAAG,MAAM,EAClF,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,GACrD,OAAO,CAAC,IAAI,CAAC;IA+MhB;;OAEG;IACH,QAAQ,IAAI,MAAM;IAKlB;;OAEG;IACH,MAAM,IAAI,GAAG;CAkBd;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;;;;;;;;;;;;KAQ9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-step.d.ts","sourceRoot":"","sources":["../../src/primitives/workflow-step.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAU,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAWxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAc,CAAC,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"workflow-step.d.ts","sourceRoot":"","sources":["../../src/primitives/workflow-step.ts"],"names":[],"mappings":"AACA,OAA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,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE;QAAE,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,EACvD,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAClD,OAAO,CAAC,IAAI,CAAC,CAAA;CAQjB;AA2LD,eAAO,MAAM,IAAI,EAMX,YAAY,CAAA"}
|
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.14.
|
|
51
|
+
define_PACKAGE_VERSIONS_default = { runtime: "1.14.1", adk: "1.14.1", sdk: "5.0.2", llmz: "0.0.37", zai: "2.5.6", cognitive: "0.3.3" };
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
|
|
@@ -8493,6 +8493,7 @@ var init_context_manager = __esm({
|
|
|
8493
8493
|
import { randomBytes } from "node:crypto";
|
|
8494
8494
|
import http from "node:http";
|
|
8495
8495
|
import https from "node:https";
|
|
8496
|
+
import { gunzipSync, inflateSync, brotliDecompressSync } from "node:zlib";
|
|
8496
8497
|
import { Dispatcher, getGlobalDispatcher, setGlobalDispatcher } from "undici";
|
|
8497
8498
|
function isBotpressUrl(fullUrl) {
|
|
8498
8499
|
try {
|
|
@@ -8524,6 +8525,31 @@ function extractIds(fullUrl, body) {
|
|
|
8524
8525
|
}
|
|
8525
8526
|
return ids;
|
|
8526
8527
|
}
|
|
8528
|
+
function decompressBody(buffer, contentEncoding) {
|
|
8529
|
+
if (!contentEncoding) {
|
|
8530
|
+
return buffer.toString("utf-8");
|
|
8531
|
+
}
|
|
8532
|
+
const encoding = contentEncoding.toLowerCase().trim();
|
|
8533
|
+
try {
|
|
8534
|
+
switch (encoding) {
|
|
8535
|
+
case "gzip":
|
|
8536
|
+
case "x-gzip":
|
|
8537
|
+
return gunzipSync(buffer).toString("utf-8");
|
|
8538
|
+
case "deflate":
|
|
8539
|
+
return inflateSync(buffer).toString("utf-8");
|
|
8540
|
+
case "br":
|
|
8541
|
+
return brotliDecompressSync(buffer).toString("utf-8");
|
|
8542
|
+
case "identity":
|
|
8543
|
+
case "":
|
|
8544
|
+
return buffer.toString("utf-8");
|
|
8545
|
+
default:
|
|
8546
|
+
return buffer.toString("utf-8");
|
|
8547
|
+
}
|
|
8548
|
+
} catch (error) {
|
|
8549
|
+
console.warn(`Failed to decompress response with encoding "${encoding}":`, error);
|
|
8550
|
+
return buffer.toString("utf-8");
|
|
8551
|
+
}
|
|
8552
|
+
}
|
|
8527
8553
|
function installHttpClientInstrumentation({ injectTraceHeader = true } = {}) {
|
|
8528
8554
|
const restores = [];
|
|
8529
8555
|
const genId = (n) => randomBytes(n).toString("hex");
|
|
@@ -8558,6 +8584,9 @@ function installHttpClientInstrumentation({ injectTraceHeader = true } = {}) {
|
|
|
8558
8584
|
if (options.headers[INSTRUMENTED_HEADER]) {
|
|
8559
8585
|
return requestFn.apply(this, args);
|
|
8560
8586
|
}
|
|
8587
|
+
if (isSilentTracing()) {
|
|
8588
|
+
return requestFn.apply(this, args);
|
|
8589
|
+
}
|
|
8561
8590
|
options.headers[INSTRUMENTED_HEADER] = "true";
|
|
8562
8591
|
const method = (options.method || "GET").toUpperCase();
|
|
8563
8592
|
const isBotpress = isBotpressUrl(urlString);
|
|
@@ -8573,12 +8602,14 @@ function installHttpClientInstrumentation({ injectTraceHeader = true } = {}) {
|
|
|
8573
8602
|
if (method === "POST" && urlString.includes("/v1/chat/actions") && bodyData?.type) {
|
|
8574
8603
|
actionName = bodyData.type;
|
|
8575
8604
|
}
|
|
8605
|
+
const isWorkflowStatusCheck = method === "GET" && /\/workflows\/[^/?]+$/.test(urlString);
|
|
8576
8606
|
const spanName = isBotpress ? "botpress.client" : "http.client";
|
|
8577
8607
|
const spanAttributes = isBotpress ? {
|
|
8578
8608
|
"botpress.method": method,
|
|
8579
8609
|
"botpress.url": urlString,
|
|
8580
8610
|
"botpress.via": "http",
|
|
8581
|
-
importance: "medium",
|
|
8611
|
+
importance: isWorkflowStatusCheck ? "low" : "medium",
|
|
8612
|
+
...isWorkflowStatusCheck && { "debug.type": "workflow-status-check" },
|
|
8582
8613
|
...ids,
|
|
8583
8614
|
...actionName && { "action.name": actionName }
|
|
8584
8615
|
} : {
|
|
@@ -8623,12 +8654,14 @@ function installHttpClientInstrumentation({ injectTraceHeader = true } = {}) {
|
|
|
8623
8654
|
req.on("response", (res) => {
|
|
8624
8655
|
span2.setAttribute(isBotpress ? "botpress.status_code" : "http.status_code", res.statusCode || 0);
|
|
8625
8656
|
const responseBodyChunks = [];
|
|
8657
|
+
const contentEncoding = res.headers["content-encoding"];
|
|
8626
8658
|
res.on("data", (chunk) => {
|
|
8627
8659
|
responseBodyChunks.push(chunk);
|
|
8628
8660
|
});
|
|
8629
8661
|
res.on("end", () => {
|
|
8630
8662
|
if (responseBodyChunks.length > 0) {
|
|
8631
|
-
const
|
|
8663
|
+
const bodyBuffer = Buffer.concat(responseBodyChunks);
|
|
8664
|
+
const bodyString = decompressBody(bodyBuffer, contentEncoding);
|
|
8632
8665
|
span2.setAttribute(isBotpress ? "botpress.response.body" : "http.response.body", bodyString);
|
|
8633
8666
|
}
|
|
8634
8667
|
if ((res.statusCode || 0) >= 400) {
|
|
@@ -8701,6 +8734,9 @@ function installHttpClientInstrumentation({ injectTraceHeader = true } = {}) {
|
|
|
8701
8734
|
}
|
|
8702
8735
|
}
|
|
8703
8736
|
}
|
|
8737
|
+
if (isSilentTracing()) {
|
|
8738
|
+
return this.d.dispatch(opts, handler);
|
|
8739
|
+
}
|
|
8704
8740
|
const method = (opts.method || "GET").toUpperCase();
|
|
8705
8741
|
const origin2 = String(opts.origin ?? "");
|
|
8706
8742
|
const path4 = String(opts.path ?? "");
|
|
@@ -8719,12 +8755,14 @@ function installHttpClientInstrumentation({ injectTraceHeader = true } = {}) {
|
|
|
8719
8755
|
if (method === "POST" && path4 === "/v1/chat/actions" && bodyData?.type) {
|
|
8720
8756
|
actionName = bodyData.type;
|
|
8721
8757
|
}
|
|
8758
|
+
const isWorkflowStatusCheck = method === "GET" && /\/workflows\/[^/?]+$/.test(fullUrl);
|
|
8722
8759
|
const spanName = isBotpress ? "botpress.client" : "http.client";
|
|
8723
8760
|
const spanAttributes = isBotpress ? {
|
|
8724
8761
|
"botpress.method": method,
|
|
8725
8762
|
"botpress.url": path4,
|
|
8726
8763
|
"botpress.via": "undici",
|
|
8727
|
-
importance: "medium",
|
|
8764
|
+
importance: isWorkflowStatusCheck ? "low" : "medium",
|
|
8765
|
+
...isWorkflowStatusCheck && { "debug.type": "workflow-status-check" },
|
|
8728
8766
|
...ids,
|
|
8729
8767
|
...actionName && { "action.name": actionName }
|
|
8730
8768
|
} : {
|
|
@@ -8775,11 +8813,18 @@ function installHttpClientInstrumentation({ injectTraceHeader = true } = {}) {
|
|
|
8775
8813
|
}
|
|
8776
8814
|
const nextOpts = { ...opts, headers };
|
|
8777
8815
|
const responseBodyChunks = [];
|
|
8816
|
+
let contentEncoding;
|
|
8778
8817
|
const wrap = {
|
|
8779
8818
|
onConnect: handler.onConnect?.bind(handler),
|
|
8780
8819
|
onUpgrade: handler.onUpgrade?.bind(handler),
|
|
8781
8820
|
onHeaders: (statusCode, rawHeaders, resume) => {
|
|
8782
8821
|
span2.setAttribute(isBotpress ? "botpress.status_code" : "http.status_code", statusCode);
|
|
8822
|
+
for (let i = 0; i < rawHeaders.length; i += 2) {
|
|
8823
|
+
if (String(rawHeaders[i]).toLowerCase() === "content-encoding") {
|
|
8824
|
+
contentEncoding = String(rawHeaders[i + 1]);
|
|
8825
|
+
break;
|
|
8826
|
+
}
|
|
8827
|
+
}
|
|
8783
8828
|
if (statusCode >= 500) {
|
|
8784
8829
|
span2.setStatus({
|
|
8785
8830
|
code: SpanStatusCode.ERROR,
|
|
@@ -8810,7 +8855,8 @@ function installHttpClientInstrumentation({ injectTraceHeader = true } = {}) {
|
|
|
8810
8855
|
},
|
|
8811
8856
|
onComplete: (trailers) => {
|
|
8812
8857
|
if (responseBodyChunks.length > 0) {
|
|
8813
|
-
const
|
|
8858
|
+
const bodyBuffer = Buffer.concat(responseBodyChunks);
|
|
8859
|
+
const bodyString = decompressBody(bodyBuffer, contentEncoding);
|
|
8814
8860
|
span2.setAttribute(isBotpress ? "botpress.response.body" : "http.response.body", bodyString);
|
|
8815
8861
|
}
|
|
8816
8862
|
span2.end();
|
|
@@ -13105,7 +13151,7 @@ var require_lodash = __commonJS({
|
|
|
13105
13151
|
return value === true || value === false || isObjectLike2(value) && baseGetTag(value) == boolTag;
|
|
13106
13152
|
}
|
|
13107
13153
|
var isBuffer2 = nativeIsBuffer || stubFalse;
|
|
13108
|
-
var
|
|
13154
|
+
var isDate3 = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
|
|
13109
13155
|
function isElement(value) {
|
|
13110
13156
|
return isObjectLike2(value) && value.nodeType === 1 && !isPlainObject2(value);
|
|
13111
13157
|
}
|
|
@@ -14240,7 +14286,7 @@ var require_lodash = __commonJS({
|
|
|
14240
14286
|
lodash.isArrayLikeObject = isArrayLikeObject;
|
|
14241
14287
|
lodash.isBoolean = isBoolean2;
|
|
14242
14288
|
lodash.isBuffer = isBuffer2;
|
|
14243
|
-
lodash.isDate =
|
|
14289
|
+
lodash.isDate = isDate3;
|
|
14244
14290
|
lodash.isElement = isElement;
|
|
14245
14291
|
lodash.isEmpty = isEmpty;
|
|
14246
14292
|
lodash.isEqual = isEqual;
|
|
@@ -46999,6 +47045,61 @@ var init_library = __esm({
|
|
|
46999
47045
|
}
|
|
47000
47046
|
});
|
|
47001
47047
|
|
|
47048
|
+
// src/primitives/date-serialization.ts
|
|
47049
|
+
function isDateMarker(value) {
|
|
47050
|
+
return typeof value === "object" && value !== null && DATE_MARKER in value && typeof value[DATE_MARKER] === "string";
|
|
47051
|
+
}
|
|
47052
|
+
function isDate2(value) {
|
|
47053
|
+
return value instanceof Date;
|
|
47054
|
+
}
|
|
47055
|
+
function serializeDates(data) {
|
|
47056
|
+
if (data === null || data === void 0) {
|
|
47057
|
+
return data;
|
|
47058
|
+
}
|
|
47059
|
+
if (isDate2(data)) {
|
|
47060
|
+
return { [DATE_MARKER]: data.toISOString() };
|
|
47061
|
+
}
|
|
47062
|
+
if (Array.isArray(data)) {
|
|
47063
|
+
return data.map((item) => serializeDates(item));
|
|
47064
|
+
}
|
|
47065
|
+
if (typeof data === "object" && data.constructor === Object) {
|
|
47066
|
+
const result = {};
|
|
47067
|
+
for (const [key, value] of Object.entries(data)) {
|
|
47068
|
+
result[key] = serializeDates(value);
|
|
47069
|
+
}
|
|
47070
|
+
return result;
|
|
47071
|
+
}
|
|
47072
|
+
return data;
|
|
47073
|
+
}
|
|
47074
|
+
function deserializeDates(data) {
|
|
47075
|
+
if (data === null || data === void 0) {
|
|
47076
|
+
return data;
|
|
47077
|
+
}
|
|
47078
|
+
if (isDateMarker(data)) {
|
|
47079
|
+
return new Date(data[DATE_MARKER]);
|
|
47080
|
+
}
|
|
47081
|
+
if (Array.isArray(data)) {
|
|
47082
|
+
return data.map((item) => deserializeDates(item));
|
|
47083
|
+
}
|
|
47084
|
+
if (typeof data === "object" && data.constructor === Object) {
|
|
47085
|
+
const result = {};
|
|
47086
|
+
for (const [key, value] of Object.entries(data)) {
|
|
47087
|
+
result[key] = deserializeDates(value);
|
|
47088
|
+
}
|
|
47089
|
+
return result;
|
|
47090
|
+
}
|
|
47091
|
+
return data;
|
|
47092
|
+
}
|
|
47093
|
+
var DATE_MARKER;
|
|
47094
|
+
var init_date_serialization = __esm({
|
|
47095
|
+
"src/primitives/date-serialization.ts"() {
|
|
47096
|
+
"use strict";
|
|
47097
|
+
init_define_BUILD();
|
|
47098
|
+
init_define_PACKAGE_VERSIONS();
|
|
47099
|
+
DATE_MARKER = "__date__";
|
|
47100
|
+
}
|
|
47101
|
+
});
|
|
47102
|
+
|
|
47002
47103
|
// src/primitives/workflow-step.ts
|
|
47003
47104
|
import { ulid } from "ulid";
|
|
47004
47105
|
import assert from "assert";
|
|
@@ -47006,7 +47107,8 @@ import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
|
47006
47107
|
import { transforms as transforms3 } from "@botpress/sdk";
|
|
47007
47108
|
async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
|
|
47008
47109
|
spanFunc,
|
|
47009
|
-
stepType
|
|
47110
|
+
stepType,
|
|
47111
|
+
stepMeta
|
|
47010
47112
|
} = {}) {
|
|
47011
47113
|
const workflowControlContext = context2.get("workflowControlContext");
|
|
47012
47114
|
workflowControlContext.signal.throwIfAborted();
|
|
@@ -47030,14 +47132,19 @@ async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
|
|
|
47030
47132
|
const steps = stepContext?.steps ?? state.value.steps;
|
|
47031
47133
|
steps[name] ??= {
|
|
47032
47134
|
attempts: 0,
|
|
47135
|
+
maxAttempts,
|
|
47033
47136
|
steps: {},
|
|
47034
47137
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
47035
47138
|
};
|
|
47139
|
+
if (stepMeta) {
|
|
47140
|
+
Object.assign(steps[name], stepMeta);
|
|
47141
|
+
console.log(`[_step] Applied stepMeta to "${name}":`, JSON.stringify(stepMeta), "\u2192 keys now:", Object.keys(steps[name]));
|
|
47142
|
+
}
|
|
47036
47143
|
if (steps[name].finishedAt) {
|
|
47037
47144
|
if (steps[name].error) {
|
|
47038
47145
|
throw new Error(steps[name].error.message);
|
|
47039
47146
|
}
|
|
47040
|
-
return steps[name].output;
|
|
47147
|
+
return deserializeDates(steps[name].output);
|
|
47041
47148
|
}
|
|
47042
47149
|
while (true) {
|
|
47043
47150
|
let shouldRetry = false;
|
|
@@ -47119,7 +47226,7 @@ async function _step(name, run, { maxAttempts = DEFAULT_MAX_ATTEMPTS } = {}, {
|
|
|
47119
47226
|
throw createStepSignal();
|
|
47120
47227
|
}
|
|
47121
47228
|
steps[name].finishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
47122
|
-
steps[name].output = result;
|
|
47229
|
+
steps[name].output = serializeDates(result);
|
|
47123
47230
|
steps[name].steps = {};
|
|
47124
47231
|
state.value.revision++;
|
|
47125
47232
|
await workflowControlContext.ack();
|
|
@@ -47167,6 +47274,7 @@ var init_workflow_step = __esm({
|
|
|
47167
47274
|
init_adk();
|
|
47168
47275
|
init_singletons();
|
|
47169
47276
|
init_workflow_utils();
|
|
47277
|
+
init_date_serialization();
|
|
47170
47278
|
DEFAULT_MAX_ATTEMPTS = 5;
|
|
47171
47279
|
MIN_STEP_REMAINING_TIME_MS = 1e4;
|
|
47172
47280
|
storage2 = getSingleton("__ADK_GLOBAL_CTX_WORKFLOW_STEP", () => new AsyncLocalStorage3());
|
|
@@ -47308,6 +47416,8 @@ var init_workflow_step = __esm({
|
|
|
47308
47416
|
{}
|
|
47309
47417
|
);
|
|
47310
47418
|
step.map = async (name, items, run, opts = {}) => {
|
|
47419
|
+
const concurrency = opts.concurrency ?? 1;
|
|
47420
|
+
const maxAttempts = opts.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
|
|
47311
47421
|
return _step(
|
|
47312
47422
|
name,
|
|
47313
47423
|
async () => {
|
|
@@ -47319,15 +47429,28 @@ var init_workflow_step = __esm({
|
|
|
47319
47429
|
async () => {
|
|
47320
47430
|
return await run(item, { i });
|
|
47321
47431
|
},
|
|
47322
|
-
opts
|
|
47432
|
+
opts,
|
|
47433
|
+
{
|
|
47434
|
+
stepType: "map-item",
|
|
47435
|
+
spanFunc: (span2) => {
|
|
47436
|
+
span2.setAttribute("workflow.map.item_index", i);
|
|
47437
|
+
span2.setAttribute("workflow.map.total", items.length);
|
|
47438
|
+
}
|
|
47439
|
+
}
|
|
47323
47440
|
);
|
|
47324
47441
|
},
|
|
47325
|
-
|
|
47442
|
+
concurrency
|
|
47326
47443
|
);
|
|
47327
47444
|
},
|
|
47328
47445
|
opts,
|
|
47329
47446
|
{
|
|
47330
|
-
stepType: "map"
|
|
47447
|
+
stepType: "map",
|
|
47448
|
+
stepMeta: { mapTotal: items.length, mapConcurrency: concurrency },
|
|
47449
|
+
spanFunc: (span2) => {
|
|
47450
|
+
span2.setAttribute("workflow.map.total", items.length);
|
|
47451
|
+
span2.setAttribute("workflow.map.concurrency", concurrency);
|
|
47452
|
+
span2.setAttribute("workflow.step.max_attempts", maxAttempts);
|
|
47453
|
+
}
|
|
47331
47454
|
}
|
|
47332
47455
|
);
|
|
47333
47456
|
};
|
|
@@ -47422,7 +47545,7 @@ function startWorkflowCancellationMonitor(props) {
|
|
|
47422
47545
|
return;
|
|
47423
47546
|
}
|
|
47424
47547
|
try {
|
|
47425
|
-
const { workflow } = await client2.getWorkflow({ id: workflowId });
|
|
47548
|
+
const { workflow } = await withSilentTracing(() => client2.getWorkflow({ id: workflowId }));
|
|
47426
47549
|
const isTerminated = workflow.status === "cancelled" || workflow.status === "failed" || workflow.status === "timedout";
|
|
47427
47550
|
if (isTerminated) {
|
|
47428
47551
|
workflowControlContext.aborted = true;
|
|
@@ -47445,6 +47568,7 @@ var init_workflow_cancellation_monitor = __esm({
|
|
|
47445
47568
|
"use strict";
|
|
47446
47569
|
init_define_BUILD();
|
|
47447
47570
|
init_define_PACKAGE_VERSIONS();
|
|
47571
|
+
init_tracing();
|
|
47448
47572
|
}
|
|
47449
47573
|
});
|
|
47450
47574
|
|
|
@@ -47497,7 +47621,9 @@ var init_workflow_instance = __esm({
|
|
|
47497
47621
|
i: z23.number().optional(),
|
|
47498
47622
|
startedAt: z23.string(),
|
|
47499
47623
|
finishedAt: z23.string().optional(),
|
|
47624
|
+
maxAttempts: z23.number().optional(),
|
|
47500
47625
|
steps: z23.record(z23.string(), workflowStepContextSchema).optional(),
|
|
47626
|
+
mapTotal: z23.number().optional(),
|
|
47501
47627
|
error: z23.object({
|
|
47502
47628
|
message: z23.string(),
|
|
47503
47629
|
failedAt: z23.string(),
|
|
@@ -49755,7 +49881,11 @@ var init_spans = __esm({
|
|
|
49755
49881
|
"workflow.step.attempt": { type: "number", required: true },
|
|
49756
49882
|
"workflow.step.output": { type: "json" },
|
|
49757
49883
|
"workflow.step.max_attempts": { type: "number" },
|
|
49758
|
-
"workflow.step.error": { type: "string" }
|
|
49884
|
+
"workflow.step.error": { type: "string" },
|
|
49885
|
+
// Map-specific attributes
|
|
49886
|
+
"workflow.map.total": { type: "number", description: "Total number of items to process in map" },
|
|
49887
|
+
"workflow.map.concurrency": { type: "number", description: "Concurrency level for map operation" },
|
|
49888
|
+
"workflow.map.item_index": { type: "number", description: "Index of item in map operation" }
|
|
49759
49889
|
}
|
|
49760
49890
|
};
|
|
49761
49891
|
ActionHandlerSpan = {
|
|
@@ -50217,7 +50347,14 @@ var init_span_helpers = __esm({
|
|
|
50217
50347
|
});
|
|
50218
50348
|
|
|
50219
50349
|
// src/telemetry/tracing.ts
|
|
50220
|
-
|
|
50350
|
+
import { AsyncLocalStorage as AsyncLocalStorage4 } from "async_hooks";
|
|
50351
|
+
function withSilentTracing(fn) {
|
|
50352
|
+
return silentTracingFlag.run(true, fn);
|
|
50353
|
+
}
|
|
50354
|
+
function isSilentTracing() {
|
|
50355
|
+
return silentTracingFlag.getStore() === true;
|
|
50356
|
+
}
|
|
50357
|
+
var import_sdk_trace_base, import_sdk_trace_node, import_resources, import_core2, spanProcessors, environmentInfo, resource, provider, contextManager, tracer, silentTracingFlag;
|
|
50221
50358
|
var init_tracing = __esm({
|
|
50222
50359
|
"src/telemetry/tracing.ts"() {
|
|
50223
50360
|
"use strict";
|
|
@@ -50265,6 +50402,7 @@ var init_tracing = __esm({
|
|
|
50265
50402
|
});
|
|
50266
50403
|
}
|
|
50267
50404
|
tracer = trace.getTracer("adk", "1.0.0");
|
|
50405
|
+
silentTracingFlag = getSingleton("__ADK_GLOBAL_SILENT_TRACING", () => new AsyncLocalStorage4());
|
|
50268
50406
|
for (const sig of ["SIGINT", "SIGTERM"]) {
|
|
50269
50407
|
process.on(sig, async () => {
|
|
50270
50408
|
await provider.forceFlush();
|