@bitfab/sdk 0.54.10 → 0.54.12
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/{chunk-6KVKJQNH.js → chunk-GZI455WP.js} +2 -2
- package/dist/{chunk-6KVKJQNH.js.map → chunk-GZI455WP.js.map} +1 -1
- package/dist/{chunk-XREH4NJT.js → chunk-I5NJU64I.js} +2 -2
- package/dist/{chunk-XREH4NJT.js.map → chunk-I5NJU64I.js.map} +1 -1
- package/dist/{chunk-3F7SICKD.js → chunk-JEFU6FTD.js} +161 -24
- package/dist/chunk-JEFU6FTD.js.map +1 -0
- package/dist/{chunk-NDWA6QLU.js → chunk-Q3X54UPA.js} +3 -3
- package/dist/{chunk-VJOLQ7UY.js → chunk-XTUINMAL.js} +2 -2
- package/dist/{http-NVPWO4TN.js → http-FJVBYZES.js} +2 -2
- package/dist/{http-NPOFVS25.js → http-X4YOOM54.js} +2 -2
- package/dist/index.cjs +187 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -11
- package/dist/index.d.ts +13 -11
- package/dist/index.js +3 -3
- package/dist/node.cjs +187 -50
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +3 -3
- package/dist/{replay-OMXCRECR.js → replay-IA5VRWHD.js} +3 -3
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-3F7SICKD.js.map +0 -1
- /package/dist/{chunk-NDWA6QLU.js.map → chunk-Q3X54UPA.js.map} +0 -0
- /package/dist/{chunk-VJOLQ7UY.js.map → chunk-XTUINMAL.js.map} +0 -0
- /package/dist/{http-NPOFVS25.js.map → http-FJVBYZES.js.map} +0 -0
- /package/dist/{http-NVPWO4TN.js.map → http-X4YOOM54.js.map} +0 -0
- /package/dist/{replay-OMXCRECR.js.map → replay-IA5VRWHD.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BitfabError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GZI455WP.js";
|
|
4
4
|
|
|
5
5
|
// src/codeChange.ts
|
|
6
6
|
var NUL = String.fromCharCode(0);
|
|
@@ -207,7 +207,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
|
|
|
207
207
|
sessionId: seedCase.sessionId
|
|
208
208
|
})
|
|
209
209
|
);
|
|
210
|
-
const { flushTraces: flushTraces2 } = await import("./http-
|
|
210
|
+
const { flushTraces: flushTraces2 } = await import("./http-FJVBYZES.js");
|
|
211
211
|
await flushTraces2(3e4);
|
|
212
212
|
return { pipeline, traceFunctionKey, traceIds };
|
|
213
213
|
}
|
|
@@ -744,4 +744,4 @@ export {
|
|
|
744
744
|
runRegistryMain,
|
|
745
745
|
runIfEntrypoint
|
|
746
746
|
};
|
|
747
|
-
//# sourceMappingURL=chunk-
|
|
747
|
+
//# sourceMappingURL=chunk-Q3X54UPA.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
replayContextReady,
|
|
7
7
|
runWithReplayContext,
|
|
8
8
|
warnOnce
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-I5NJU64I.js";
|
|
10
10
|
import {
|
|
11
11
|
runWithCaptureSuppressed
|
|
12
12
|
} from "./chunk-VCRFFCLY.js";
|
|
@@ -1257,4 +1257,4 @@ export {
|
|
|
1257
1257
|
sleepForReplayPersistence,
|
|
1258
1258
|
replay
|
|
1259
1259
|
};
|
|
1260
|
-
//# sourceMappingURL=chunk-
|
|
1260
|
+
//# sourceMappingURL=chunk-XTUINMAL.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GZI455WP.js";
|
|
10
10
|
export {
|
|
11
11
|
BitfabError,
|
|
12
12
|
HttpClient,
|
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
parseRetryAfterMs,
|
|
17
17
|
serializePayloadBody
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=http-
|
|
19
|
+
//# sourceMappingURL=http-FJVBYZES.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-I5NJU64I.js";
|
|
10
10
|
import "./chunk-VCRFFCLY.js";
|
|
11
11
|
export {
|
|
12
12
|
BitfabError,
|
|
@@ -17,4 +17,4 @@ export {
|
|
|
17
17
|
parseRetryAfterMs,
|
|
18
18
|
serializePayloadBody
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=http-
|
|
20
|
+
//# sourceMappingURL=http-X4YOOM54.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ var __version__, __packageName__;
|
|
|
42
42
|
var init_version_generated = __esm({
|
|
43
43
|
"src/version.generated.ts"() {
|
|
44
44
|
"use strict";
|
|
45
|
-
__version__ = "0.54.
|
|
45
|
+
__version__ = "0.54.12";
|
|
46
46
|
__packageName__ = "@bitfab/sdk";
|
|
47
47
|
}
|
|
48
48
|
});
|
|
@@ -68,20 +68,20 @@ var init_traceCompletion = __esm({
|
|
|
68
68
|
this.closed = /* @__PURE__ */ new Map();
|
|
69
69
|
}
|
|
70
70
|
state(traceId) {
|
|
71
|
-
let
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
this.traces.set(traceId,
|
|
71
|
+
let state2 = this.traces.get(traceId);
|
|
72
|
+
if (state2 === void 0) {
|
|
73
|
+
state2 = { spanIds: /* @__PURE__ */ new Set(), active: /* @__PURE__ */ new Set() };
|
|
74
|
+
this.traces.set(traceId, state2);
|
|
75
75
|
}
|
|
76
|
-
return
|
|
76
|
+
return state2;
|
|
77
77
|
}
|
|
78
78
|
start(traceId, spanId) {
|
|
79
79
|
if (this.closed.has(traceId)) {
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
const state2 = this.state(traceId);
|
|
83
|
+
state2.spanIds.add(spanId);
|
|
84
|
+
state2.active.add(spanId);
|
|
85
85
|
}
|
|
86
86
|
open(traceId) {
|
|
87
87
|
if (!this.closed.has(traceId)) {
|
|
@@ -97,24 +97,24 @@ var init_traceCompletion = __esm({
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
end(traceId, spanId) {
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
this.drain(traceId,
|
|
100
|
+
const state2 = this.traces.get(traceId);
|
|
101
|
+
if (state2 !== void 0) {
|
|
102
|
+
state2.active.delete(spanId);
|
|
103
|
+
this.drain(traceId, state2);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
abort(traceId, spanId) {
|
|
107
|
-
const
|
|
108
|
-
if (
|
|
107
|
+
const state2 = this.traces.get(traceId);
|
|
108
|
+
if (state2 === void 0) {
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (
|
|
111
|
+
state2.active.delete(spanId);
|
|
112
|
+
state2.spanIds.delete(spanId);
|
|
113
|
+
if (state2.active.size === 0 && state2.spanIds.size === 0 && state2.complete === void 0) {
|
|
114
114
|
this.traces.delete(traceId);
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
|
-
this.drain(traceId,
|
|
117
|
+
this.drain(traceId, state2);
|
|
118
118
|
}
|
|
119
119
|
close(traceId, complete, dropped = false) {
|
|
120
120
|
const count = this.closed.get(traceId);
|
|
@@ -122,29 +122,29 @@ var init_traceCompletion = __esm({
|
|
|
122
122
|
complete(count);
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
125
|
+
const state2 = this.traces.get(traceId);
|
|
126
|
+
if (state2 === void 0) {
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
state2.complete = complete;
|
|
130
130
|
if (dropped) {
|
|
131
|
-
|
|
131
|
+
state2.active.clear();
|
|
132
132
|
}
|
|
133
|
-
this.drain(traceId,
|
|
133
|
+
this.drain(traceId, state2);
|
|
134
134
|
}
|
|
135
|
-
drain(traceId,
|
|
136
|
-
if (
|
|
135
|
+
drain(traceId, state2) {
|
|
136
|
+
if (state2.active.size !== 0 || state2.complete === void 0) {
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
139
|
this.traces.delete(traceId);
|
|
140
|
-
this.closed.set(traceId,
|
|
140
|
+
this.closed.set(traceId, state2.spanIds.size);
|
|
141
141
|
if (this.closed.size > 1024) {
|
|
142
142
|
const oldest = this.closed.keys().next().value;
|
|
143
143
|
if (oldest !== void 0) {
|
|
144
144
|
this.closed.delete(oldest);
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
state2.complete(state2.spanIds.size);
|
|
148
148
|
}
|
|
149
149
|
};
|
|
150
150
|
}
|
|
@@ -395,8 +395,8 @@ function text(value) {
|
|
|
395
395
|
const trimmed = value?.trim();
|
|
396
396
|
return trimmed ? trimmed : null;
|
|
397
397
|
}
|
|
398
|
-
function isEmptyGitState(
|
|
399
|
-
return Object.values(
|
|
398
|
+
function isEmptyGitState(state2) {
|
|
399
|
+
return Object.values(state2).every((value) => value === null);
|
|
400
400
|
}
|
|
401
401
|
async function resolveGitState(cwd) {
|
|
402
402
|
const git = await gitRunner({
|
|
@@ -417,14 +417,14 @@ async function resolveGitState(cwd) {
|
|
|
417
417
|
if (!root) {
|
|
418
418
|
return null;
|
|
419
419
|
}
|
|
420
|
-
const
|
|
420
|
+
const state2 = {
|
|
421
421
|
githubEmail: text(email),
|
|
422
422
|
branch: text(branch),
|
|
423
423
|
commitSha: sha(commitSha),
|
|
424
424
|
baseSha: sha(baseSha),
|
|
425
425
|
experimentSha: await resolveWorkingTreeSha(run, root.trim())
|
|
426
426
|
};
|
|
427
|
-
return isEmptyGitState(
|
|
427
|
+
return isEmptyGitState(state2) ? null : state2;
|
|
428
428
|
}
|
|
429
429
|
async function resolveWorkingTreeSha(run, root) {
|
|
430
430
|
let indexPath;
|
|
@@ -6971,6 +6971,83 @@ var BitfabOpenAIAgentHandler = class {
|
|
|
6971
6971
|
}
|
|
6972
6972
|
};
|
|
6973
6973
|
|
|
6974
|
+
// src/openaiAgentsSpanContext.ts
|
|
6975
|
+
var OPENAI_AGENTS_CONTEXT_STORAGE = /* @__PURE__ */ Symbol.for(
|
|
6976
|
+
"openai.agents.core.asyncLocalStorage"
|
|
6977
|
+
);
|
|
6978
|
+
var MAX_OPENAI_AGENTS_SPAN_CHAIN = 64;
|
|
6979
|
+
var spanGlobal = globalThis;
|
|
6980
|
+
var state = spanGlobal.__bitfabOpenAiAgentsSpansV1 ?? {
|
|
6981
|
+
bitfabTraceIds: /* @__PURE__ */ new Map(),
|
|
6982
|
+
endedSpanIds: /* @__PURE__ */ new Map()
|
|
6983
|
+
};
|
|
6984
|
+
spanGlobal.__bitfabOpenAiAgentsSpansV1 = state;
|
|
6985
|
+
function mapOpenAiAgentsTrace(agentsTraceId, bitfabTraceId) {
|
|
6986
|
+
state.bitfabTraceIds.set(agentsTraceId, bitfabTraceId);
|
|
6987
|
+
}
|
|
6988
|
+
function unmapOpenAiAgentsTrace(agentsTraceId) {
|
|
6989
|
+
state.bitfabTraceIds.delete(agentsTraceId);
|
|
6990
|
+
state.endedSpanIds.delete(agentsTraceId);
|
|
6991
|
+
}
|
|
6992
|
+
function endOpenAiAgentsSpan(agentsTraceId, spanId) {
|
|
6993
|
+
if (!state.bitfabTraceIds.has(agentsTraceId)) {
|
|
6994
|
+
return;
|
|
6995
|
+
}
|
|
6996
|
+
const ended = state.endedSpanIds.get(agentsTraceId) ?? /* @__PURE__ */ new Set();
|
|
6997
|
+
ended.add(spanId);
|
|
6998
|
+
state.endedSpanIds.set(agentsTraceId, ended);
|
|
6999
|
+
}
|
|
7000
|
+
function isOpenAiAgentsContextStorage(value) {
|
|
7001
|
+
return value !== null && typeof value === "object" && typeof value.getStore === "function";
|
|
7002
|
+
}
|
|
7003
|
+
function currentOpenAiAgentsSpan() {
|
|
7004
|
+
const storage2 = spanGlobal[OPENAI_AGENTS_CONTEXT_STORAGE];
|
|
7005
|
+
if (!isOpenAiAgentsContextStorage(storage2)) {
|
|
7006
|
+
return void 0;
|
|
7007
|
+
}
|
|
7008
|
+
try {
|
|
7009
|
+
const store = storage2.getStore();
|
|
7010
|
+
return store?.active === true ? store.span ?? void 0 : void 0;
|
|
7011
|
+
} catch {
|
|
7012
|
+
return void 0;
|
|
7013
|
+
}
|
|
7014
|
+
}
|
|
7015
|
+
function currentOpenAiAgentsSpans() {
|
|
7016
|
+
const spans = [];
|
|
7017
|
+
let span = currentOpenAiAgentsSpan();
|
|
7018
|
+
while (span !== void 0 && spans.length < MAX_OPENAI_AGENTS_SPAN_CHAIN) {
|
|
7019
|
+
spans.push(span);
|
|
7020
|
+
span = span.previousSpan ?? void 0;
|
|
7021
|
+
}
|
|
7022
|
+
return spans;
|
|
7023
|
+
}
|
|
7024
|
+
function openAiAgentsSpanChain() {
|
|
7025
|
+
if (state.bitfabTraceIds.size === 0) {
|
|
7026
|
+
return [];
|
|
7027
|
+
}
|
|
7028
|
+
return currentOpenAiAgentsSpans().map((span) => span.spanId).filter((spanId) => typeof spanId === "string");
|
|
7029
|
+
}
|
|
7030
|
+
function openAiAgentsParentSpanId(bitfabTraceId, enclosingSpanIds) {
|
|
7031
|
+
if (state.bitfabTraceIds.size === 0) {
|
|
7032
|
+
return void 0;
|
|
7033
|
+
}
|
|
7034
|
+
for (const span of currentOpenAiAgentsSpans()) {
|
|
7035
|
+
if (typeof span.spanId !== "string" || typeof span.traceId !== "string") {
|
|
7036
|
+
return void 0;
|
|
7037
|
+
}
|
|
7038
|
+
if (state.bitfabTraceIds.get(span.traceId) !== bitfabTraceId) {
|
|
7039
|
+
return void 0;
|
|
7040
|
+
}
|
|
7041
|
+
if (enclosingSpanIds?.includes(span.spanId)) {
|
|
7042
|
+
return void 0;
|
|
7043
|
+
}
|
|
7044
|
+
if (!state.endedSpanIds.get(span.traceId)?.has(span.spanId)) {
|
|
7045
|
+
return span.spanId;
|
|
7046
|
+
}
|
|
7047
|
+
}
|
|
7048
|
+
return void 0;
|
|
7049
|
+
}
|
|
7050
|
+
|
|
6974
7051
|
// src/client.ts
|
|
6975
7052
|
init_policyRefresh();
|
|
6976
7053
|
init_randomUuid();
|
|
@@ -7120,18 +7197,42 @@ var RIVET_TOP_LEVEL_EFFECTS = [
|
|
|
7120
7197
|
"broadcast",
|
|
7121
7198
|
"saveState",
|
|
7122
7199
|
"sleep",
|
|
7123
|
-
"destroy"
|
|
7200
|
+
"destroy",
|
|
7201
|
+
"step",
|
|
7202
|
+
"tryStep",
|
|
7203
|
+
"try",
|
|
7204
|
+
"loop",
|
|
7205
|
+
"sleepUntil",
|
|
7206
|
+
"rollbackCheckpoint",
|
|
7207
|
+
"join",
|
|
7208
|
+
"race",
|
|
7209
|
+
"removed",
|
|
7210
|
+
"getVersion"
|
|
7124
7211
|
];
|
|
7125
7212
|
var TOP_LEVEL_UNAVAILABLE_CAPABILITIES = /* @__PURE__ */ new Set([
|
|
7126
7213
|
"conn",
|
|
7127
7214
|
"conns",
|
|
7128
|
-
"log",
|
|
7129
7215
|
"request",
|
|
7130
7216
|
"actorRuntimeSocket",
|
|
7131
7217
|
"keepAwake",
|
|
7132
7218
|
"waitUntil",
|
|
7133
7219
|
"client"
|
|
7134
7220
|
]);
|
|
7221
|
+
var replayLog = () => void 0;
|
|
7222
|
+
var replayLogger = {
|
|
7223
|
+
level: "silent",
|
|
7224
|
+
msgPrefix: void 0,
|
|
7225
|
+
fatal: replayLog,
|
|
7226
|
+
trace: replayLog,
|
|
7227
|
+
silent: replayLog,
|
|
7228
|
+
debug: replayLog,
|
|
7229
|
+
info: replayLog,
|
|
7230
|
+
warn: replayLog,
|
|
7231
|
+
error: replayLog,
|
|
7232
|
+
child: () => replayLogger,
|
|
7233
|
+
bindings: () => ({}),
|
|
7234
|
+
isLevelEnabled: () => false
|
|
7235
|
+
};
|
|
7135
7236
|
var SYNC_VOID_EFFECTS = /* @__PURE__ */ new Set([
|
|
7136
7237
|
"broadcast",
|
|
7137
7238
|
"sleep",
|
|
@@ -7161,16 +7262,28 @@ function snapshotContext(context) {
|
|
|
7161
7262
|
"state",
|
|
7162
7263
|
"vars",
|
|
7163
7264
|
"actorId",
|
|
7265
|
+
"workflowId",
|
|
7164
7266
|
"name",
|
|
7165
7267
|
"key",
|
|
7166
|
-
"region"
|
|
7167
|
-
"aborted"
|
|
7268
|
+
"region"
|
|
7168
7269
|
]) {
|
|
7169
7270
|
const value = readProperty(source, property);
|
|
7170
7271
|
if (value !== void 0) {
|
|
7171
7272
|
snapshot[property] = value;
|
|
7172
7273
|
}
|
|
7173
7274
|
}
|
|
7275
|
+
const aborted = readProperty(source, "aborted");
|
|
7276
|
+
if (typeof aborted === "boolean") {
|
|
7277
|
+
snapshot.aborted = aborted;
|
|
7278
|
+
} else {
|
|
7279
|
+
const abortSignal = readProperty(source, "abortSignal");
|
|
7280
|
+
if (isRecord5(abortSignal)) {
|
|
7281
|
+
const signalAborted = readProperty(abortSignal, "aborted");
|
|
7282
|
+
if (typeof signalAborted === "boolean") {
|
|
7283
|
+
snapshot.aborted = signalAborted;
|
|
7284
|
+
}
|
|
7285
|
+
}
|
|
7286
|
+
}
|
|
7174
7287
|
return snapshot;
|
|
7175
7288
|
}
|
|
7176
7289
|
function unavailableCapability(path) {
|
|
@@ -7262,7 +7375,8 @@ var BitfabRivetIntegration = class {
|
|
|
7262
7375
|
}
|
|
7263
7376
|
/**
|
|
7264
7377
|
* Adapt a traced function into a Rivet handler whose first argument is the
|
|
7265
|
-
* live actor context. The context is not added to the traced
|
|
7378
|
+
* live actor or workflow context. The context is not added to the traced
|
|
7379
|
+
* root's inputs.
|
|
7266
7380
|
*/
|
|
7267
7381
|
bind(fn) {
|
|
7268
7382
|
const integration = this;
|
|
@@ -7273,7 +7387,8 @@ var BitfabRivetIntegration = class {
|
|
|
7273
7387
|
/**
|
|
7274
7388
|
* Return the current Rivet context proxy. In production it delegates to the
|
|
7275
7389
|
* bound live context. During replay it hydrates recorded actor state and
|
|
7276
|
-
* intercepts supported effects without requiring a live Rivet actor
|
|
7390
|
+
* intercepts supported effects without requiring a live Rivet actor or
|
|
7391
|
+
* workflow.
|
|
7277
7392
|
*/
|
|
7278
7393
|
getContext() {
|
|
7279
7394
|
const replay2 = getReplayContext();
|
|
@@ -7357,6 +7472,12 @@ var BitfabRivetIntegration = class {
|
|
|
7357
7472
|
if (property === "setPreventSleep" && replay2) {
|
|
7358
7473
|
return (_preventSleep) => void 0;
|
|
7359
7474
|
}
|
|
7475
|
+
if (property === "isEvicted" && replay2) {
|
|
7476
|
+
return () => replayTarget.abortSignal?.aborted === true;
|
|
7477
|
+
}
|
|
7478
|
+
if (property === "log" && replay2) {
|
|
7479
|
+
return replayLogger;
|
|
7480
|
+
}
|
|
7360
7481
|
if (replay2 && typeof property === "string" && TOP_LEVEL_UNAVAILABLE_CAPABILITIES.has(property)) {
|
|
7361
7482
|
throw unavailableCapability(property);
|
|
7362
7483
|
}
|
|
@@ -7530,7 +7651,7 @@ var BitfabRivetIntegration = class {
|
|
|
7530
7651
|
return { ...value, complete };
|
|
7531
7652
|
}
|
|
7532
7653
|
queueCallIsCompletable(effect, args) {
|
|
7533
|
-
const options = effect === "queue.waitForNames" ? args[1] : args[0];
|
|
7654
|
+
const options = effect === "queue.waitForNames" || (effect === "queue.next" || effect === "queue.nextBatch") && typeof args[0] === "string" ? args[1] : args[0];
|
|
7534
7655
|
return isRecord5(options) && options.completable === true;
|
|
7535
7656
|
}
|
|
7536
7657
|
createQueueIterator(queue, options) {
|
|
@@ -7694,6 +7815,9 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7694
7815
|
const activeContext = this.getActiveSpanContext?.();
|
|
7695
7816
|
if (activeContext) {
|
|
7696
7817
|
this.activeSpanMappings[trace.traceId] = activeContext;
|
|
7818
|
+
if (this.shouldRecord()) {
|
|
7819
|
+
mapOpenAiAgentsTrace(trace.traceId, activeContext.traceId);
|
|
7820
|
+
}
|
|
7697
7821
|
}
|
|
7698
7822
|
const canonicalTraceId = activeContext?.traceId ?? this.getCanonicalTraceId(trace.traceId);
|
|
7699
7823
|
this.canonicalTraceIds[trace.traceId] = canonicalTraceId;
|
|
@@ -7731,6 +7855,7 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7731
7855
|
}
|
|
7732
7856
|
this.endedTraces.delete(traceId);
|
|
7733
7857
|
delete this.activeSpanMappings[traceId];
|
|
7858
|
+
unmapOpenAiAgentsTrace(traceId);
|
|
7734
7859
|
delete this.canonicalTraceIds[traceId];
|
|
7735
7860
|
delete this.activeTraces[traceId];
|
|
7736
7861
|
}
|
|
@@ -7755,6 +7880,9 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7755
7880
|
async onSpanEnd(span) {
|
|
7756
7881
|
const originalTraceId = span.traceId ?? "";
|
|
7757
7882
|
const traceId = this.activeSpanMappings[originalTraceId]?.traceId ?? originalTraceId;
|
|
7883
|
+
if (span.spanId !== void 0) {
|
|
7884
|
+
endOpenAiAgentsSpan(originalTraceId, span.spanId);
|
|
7885
|
+
}
|
|
7758
7886
|
try {
|
|
7759
7887
|
this.sendSpan(span);
|
|
7760
7888
|
} finally {
|
|
@@ -7775,6 +7903,9 @@ var BitfabOpenAITracingProcessor = class {
|
|
|
7775
7903
|
* Called when the trace processor is shutting down.
|
|
7776
7904
|
*/
|
|
7777
7905
|
async shutdown(timeout) {
|
|
7906
|
+
for (const traceId of Object.keys(this.activeSpanMappings)) {
|
|
7907
|
+
unmapOpenAiAgentsTrace(traceId);
|
|
7908
|
+
}
|
|
7778
7909
|
this.activeTraces = {};
|
|
7779
7910
|
this.activeSpanMappings = {};
|
|
7780
7911
|
this.canonicalTraceIds = {};
|
|
@@ -8932,16 +9063,16 @@ var Bitfab = class {
|
|
|
8932
9063
|
this.simulationPlan.send(payload, rootTraceFunctionKeyOf(payload), submit);
|
|
8933
9064
|
}
|
|
8934
9065
|
refreshAutoTraceCapturePolicy(traceFunctionKey) {
|
|
8935
|
-
const
|
|
8936
|
-
this.autoTracePolicyRefreshes.set(traceFunctionKey,
|
|
8937
|
-
|
|
9066
|
+
const state2 = this.autoTracePolicyRefreshes.get(traceFunctionKey) ?? new PolicyRefresh();
|
|
9067
|
+
this.autoTracePolicyRefreshes.set(traceFunctionKey, state2);
|
|
9068
|
+
state2.run(
|
|
8938
9069
|
() => this.httpClient.getAutoTracePolicy(
|
|
8939
9070
|
traceFunctionKey,
|
|
8940
9071
|
AUTO_TRACE_PROTOCOL
|
|
8941
9072
|
),
|
|
8942
9073
|
(policy) => {
|
|
8943
9074
|
if (policy.protocol !== AUTO_TRACE_PROTOCOL) {
|
|
8944
|
-
|
|
9075
|
+
state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
|
|
8945
9076
|
return;
|
|
8946
9077
|
}
|
|
8947
9078
|
const functionIds = Array.isArray(policy.functionIds) ? policy.functionIds.filter(
|
|
@@ -8952,10 +9083,10 @@ var Bitfab = class {
|
|
|
8952
9083
|
traceFunctionKey,
|
|
8953
9084
|
policy.revision === null ? void 0 : functionIds
|
|
8954
9085
|
);
|
|
8955
|
-
|
|
9086
|
+
state2.hold(AUTO_TRACE_POLICY_REFRESH_MS);
|
|
8956
9087
|
},
|
|
8957
9088
|
() => {
|
|
8958
|
-
|
|
9089
|
+
state2.hold(AUTO_TRACE_POLICY_RETRY_MS);
|
|
8959
9090
|
}
|
|
8960
9091
|
);
|
|
8961
9092
|
}
|
|
@@ -9261,9 +9392,9 @@ var Bitfab = class {
|
|
|
9261
9392
|
});
|
|
9262
9393
|
}
|
|
9263
9394
|
/**
|
|
9264
|
-
* Get the first-class Rivet actor-context integration for an
|
|
9265
|
-
* root. The integration binds context and records effect
|
|
9266
|
-
* creates another root.
|
|
9395
|
+
* Get the first-class Rivet actor/workflow-context integration for an
|
|
9396
|
+
* existing trace root. The integration binds context and records effect
|
|
9397
|
+
* spans; it never creates another root.
|
|
9267
9398
|
*
|
|
9268
9399
|
* @param traceFunctionKey - Key used by the enclosing `withTrace()` root
|
|
9269
9400
|
* @param options - Explicit per-context-path replay mocking policy
|
|
@@ -9566,7 +9697,11 @@ var Bitfab = class {
|
|
|
9566
9697
|
const seedCtxForTraceId = parentContext ? null : getSeedContext();
|
|
9567
9698
|
const traceId = parentContext?.traceId ?? replayCtxForTraceId?.traceId ?? seedCtxForTraceId?.traceId ?? randomUuid();
|
|
9568
9699
|
const spanId = randomUuid();
|
|
9569
|
-
const
|
|
9700
|
+
const openAiAgentsParent = parentContext !== void 0 && options.instrumentation === "trace" ? openAiAgentsParentSpanId(
|
|
9701
|
+
parentContext.traceId,
|
|
9702
|
+
parentContext.openAiAgentsSpanIds
|
|
9703
|
+
) : void 0;
|
|
9704
|
+
const parentSpanId = openAiAgentsParent ?? parentContext?.spanId ?? null;
|
|
9570
9705
|
const isRootSpan = parentSpanId === null;
|
|
9571
9706
|
if (options.enclosingTrace !== void 0) {
|
|
9572
9707
|
options.enclosingTrace.link.traceId = traceId;
|
|
@@ -9580,11 +9715,13 @@ var Bitfab = class {
|
|
|
9580
9715
|
parentContext?.surface,
|
|
9581
9716
|
traceFunctionKey
|
|
9582
9717
|
);
|
|
9718
|
+
const openAiAgentsSpanIds = openAiAgentsSpanChain();
|
|
9583
9719
|
const newContext = {
|
|
9584
9720
|
traceId,
|
|
9585
9721
|
spanId,
|
|
9586
9722
|
contexts: [],
|
|
9587
|
-
...surface !== void 0 && { surface }
|
|
9723
|
+
...surface !== void 0 && { surface },
|
|
9724
|
+
...openAiAgentsSpanIds.length > 0 && { openAiAgentsSpanIds }
|
|
9588
9725
|
};
|
|
9589
9726
|
newStack = [...currentStack, newContext];
|
|
9590
9727
|
const inputs = args;
|