@bitfab/sdk 0.65.7 → 0.65.9
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/cloudReplay.py +130 -3
- package/dist/baml.cjs +12 -0
- package/dist/baml.cjs.map +1 -0
- package/dist/baml.d.cts +1 -0
- package/dist/baml.d.ts +1 -0
- package/dist/baml.js +8 -0
- package/dist/baml.js.map +1 -0
- package/dist/bamlPeer-BUoZgNxZ.cjs +88 -0
- package/dist/bamlPeer-BUoZgNxZ.cjs.map +1 -0
- package/dist/bamlPeer-CIVwS68E.js +28 -0
- package/dist/bamlPeer-CIVwS68E.js.map +1 -0
- package/dist/{http-BaLzqv9W.js → http-DUDL3FGE.js} +2 -2
- package/dist/{http-BaLzqv9W.js.map → http-DUDL3FGE.js.map} +1 -1
- package/dist/http-DX-fpUSu.cjs +2306 -0
- package/dist/http-DX-fpUSu.cjs.map +1 -0
- package/dist/{index-qVS-HeqB.d.cts → index-C2b7Qyjw.d.cts} +1 -1
- package/dist/{index-qVS-HeqB.d.ts → index-C2b7Qyjw.d.ts} +1 -1
- package/dist/index.cjs +7 -6
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/node.cjs +7 -6
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +2 -2
- package/dist/registryCommand-Di8x0YoJ.js.map +1 -1
- package/dist/{src-DgkDt32g.cjs → src-BWZx-C1S.cjs} +324 -2440
- package/dist/src-BWZx-C1S.cjs.map +1 -0
- package/dist/{src-BblbvWfU.js → src-DYCb-06l.js} +147 -52
- package/dist/src-DYCb-06l.js.map +1 -0
- package/package.json +11 -1
- package/dist/src-BblbvWfU.js.map +0 -1
- package/dist/src-DgkDt32g.cjs.map +0 -1
package/cloudReplay.py
CHANGED
|
@@ -154,6 +154,7 @@ CODE_CHANGE_PATH_ENV = "BITFAB_CODE_CHANGE_PATH"
|
|
|
154
154
|
CODE_CHANGE_MAX_FILES = 60
|
|
155
155
|
CODE_CHANGE_MAX_FILE_BYTES = 500_000
|
|
156
156
|
CODE_CHANGE_MAX_TOTAL_BYTES = 2_000_000
|
|
157
|
+
BRANCH_WALK_LIMIT = 1000
|
|
157
158
|
CHECK_ARGUMENTS_SECONDS = 300
|
|
158
159
|
CHECK_ARGUMENTS_FLAG = "--check-arguments"
|
|
159
160
|
REPLAY_ARGUMENTS_FLAG = "--replay-arguments"
|
|
@@ -933,6 +934,98 @@ def current_branch(root):
|
|
|
933
934
|
return None
|
|
934
935
|
|
|
935
936
|
|
|
937
|
+
def quiet_git(root, *args):
|
|
938
|
+
try:
|
|
939
|
+
return git(root, *args)
|
|
940
|
+
except CommandError:
|
|
941
|
+
return ""
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
def default_branch(root):
|
|
945
|
+
origin_head = quiet_git(root, "rev-parse", "--abbrev-ref", "origin/HEAD")
|
|
946
|
+
candidates = [
|
|
947
|
+
origin_head if origin_head and origin_head != "origin/HEAD" else None,
|
|
948
|
+
"origin/main",
|
|
949
|
+
"origin/master",
|
|
950
|
+
"main",
|
|
951
|
+
"master",
|
|
952
|
+
]
|
|
953
|
+
return next(
|
|
954
|
+
(
|
|
955
|
+
ref
|
|
956
|
+
for ref in dict.fromkeys(filter(None, candidates))
|
|
957
|
+
if quiet_git(root, "rev-parse", "--verify", "-q", f"{ref}^{{commit}}")
|
|
958
|
+
),
|
|
959
|
+
None,
|
|
960
|
+
)
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
def current_branch_refs(root):
|
|
964
|
+
branch = current_branch(root)
|
|
965
|
+
if not branch:
|
|
966
|
+
return set()
|
|
967
|
+
return {f"refs/heads/{branch}"} | {
|
|
968
|
+
f"refs/remotes/{remote}/{branch}"
|
|
969
|
+
for remote in quiet_git(root, "remote").split()
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
|
|
973
|
+
def own_branch_refs(root):
|
|
974
|
+
upstream = quiet_git(root, "rev-parse", "--symbolic-full-name", "@{upstream}")
|
|
975
|
+
own = current_branch_refs(root)
|
|
976
|
+
if upstream:
|
|
977
|
+
own.add(upstream)
|
|
978
|
+
return own
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
def on_default_branch(root, default):
|
|
982
|
+
full_name = quiet_git(root, "rev-parse", "--symbolic-full-name", default)
|
|
983
|
+
return bool(full_name) and full_name in current_branch_refs(root)
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
def branch_tips(root):
|
|
987
|
+
own = own_branch_refs(root)
|
|
988
|
+
listing = quiet_git(
|
|
989
|
+
root,
|
|
990
|
+
"for-each-ref",
|
|
991
|
+
"--format=%(objectname) %(refname)",
|
|
992
|
+
"refs/heads",
|
|
993
|
+
"refs/remotes",
|
|
994
|
+
)
|
|
995
|
+
tips = {}
|
|
996
|
+
for line in listing.splitlines():
|
|
997
|
+
sha, _, ref = line.partition(" ")
|
|
998
|
+
if ref and ref not in own and not ref.endswith("/HEAD"):
|
|
999
|
+
tips.setdefault(
|
|
1000
|
+
sha, ref.removeprefix("refs/heads/").removeprefix("refs/remotes/")
|
|
1001
|
+
)
|
|
1002
|
+
return tips
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
def branch_point(root):
|
|
1006
|
+
head = quiet_git(root, "rev-parse", "HEAD")
|
|
1007
|
+
if not head:
|
|
1008
|
+
return None
|
|
1009
|
+
default = default_branch(root)
|
|
1010
|
+
if default and on_default_branch(root, default):
|
|
1011
|
+
return None
|
|
1012
|
+
default_base = quiet_git(root, "merge-base", "HEAD", default) if default else ""
|
|
1013
|
+
walk = ["rev-list", "--first-parent", f"--max-count={BRANCH_WALK_LIMIT}", "HEAD"]
|
|
1014
|
+
if default_base:
|
|
1015
|
+
walk.append(f"^{default_base}")
|
|
1016
|
+
tips = branch_tips(root)
|
|
1017
|
+
for sha in quiet_git(root, *walk).split()[1:]:
|
|
1018
|
+
if sha in tips:
|
|
1019
|
+
return {"sha": sha, "ref": tips[sha]}
|
|
1020
|
+
if default_base and default_base != head:
|
|
1021
|
+
return {"sha": default_base, "ref": default}
|
|
1022
|
+
return None
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
def replay_artifact(path):
|
|
1026
|
+
return path == ".bitfab" or path.startswith(".bitfab/")
|
|
1027
|
+
|
|
1028
|
+
|
|
936
1029
|
def sensitive(path):
|
|
937
1030
|
parts = Path(path).parts
|
|
938
1031
|
name = Path(path).name.lower()
|
|
@@ -1033,12 +1126,20 @@ def snapshot(
|
|
|
1033
1126
|
}
|
|
1034
1127
|
if preview:
|
|
1035
1128
|
return summary
|
|
1129
|
+
code_change_base = request.get("codeChangeBase") or {}
|
|
1130
|
+
extra_parent = (
|
|
1131
|
+
["-p", code_change_base["sha"]]
|
|
1132
|
+
if not any(not replay_artifact(path) for _, path in changes)
|
|
1133
|
+
and SHA.fullmatch(str(code_change_base.get("sha", "")))
|
|
1134
|
+
else []
|
|
1135
|
+
)
|
|
1036
1136
|
sha = git(
|
|
1037
1137
|
root,
|
|
1038
1138
|
"commit-tree",
|
|
1039
1139
|
tree,
|
|
1040
1140
|
"-p",
|
|
1041
1141
|
head,
|
|
1142
|
+
*extra_parent,
|
|
1042
1143
|
input=f"{snapshot_subject(request['id'], on_push)}\n\n{json.dumps(request)}\n",
|
|
1043
1144
|
)
|
|
1044
1145
|
return {**summary, "sha": sha}
|
|
@@ -1360,6 +1461,9 @@ def submit(root, repo, workflow, parsed, path):
|
|
|
1360
1461
|
branch = current_branch(root)
|
|
1361
1462
|
if branch:
|
|
1362
1463
|
request["branch"] = branch
|
|
1464
|
+
code_change_base = branch_point(root)
|
|
1465
|
+
if code_change_base:
|
|
1466
|
+
request["codeChangeBase"] = code_change_base
|
|
1363
1467
|
check_arguments(parsed["replay"])
|
|
1364
1468
|
allowed = allowed_files(root, parsed)
|
|
1365
1469
|
if "--cloud-preview" in parsed["switches"]:
|
|
@@ -2067,7 +2171,9 @@ def changed_paths(root, base, commit):
|
|
|
2067
2171
|
yield status, before_path, path
|
|
2068
2172
|
|
|
2069
2173
|
|
|
2070
|
-
def snapshot_code_change(
|
|
2174
|
+
def snapshot_code_change(
|
|
2175
|
+
root, base, commit, name, against="uncommitted (vs HEAD)", subject_ref=None
|
|
2176
|
+
):
|
|
2071
2177
|
files, total = [], 0
|
|
2072
2178
|
for status, before_path, path in changed_paths(root, base, commit):
|
|
2073
2179
|
if len(files) >= CODE_CHANGE_MAX_FILES:
|
|
@@ -2083,14 +2189,34 @@ def snapshot_code_change(root, base, commit, name):
|
|
|
2083
2189
|
files.append({"path": path, "before": before, "after": after})
|
|
2084
2190
|
if not files:
|
|
2085
2191
|
return None
|
|
2086
|
-
head = (name or "").strip() or git(
|
|
2192
|
+
head = (name or "").strip() or git(
|
|
2193
|
+
root, "log", "-1", "--format=%s", subject_ref or base
|
|
2194
|
+
)
|
|
2087
2195
|
word = "file" if len(files) == 1 else "files"
|
|
2088
2196
|
return {
|
|
2089
|
-
"description": f"{head or 'Working-tree change'} ({len(files)} {word} changed
|
|
2197
|
+
"description": f"{head or 'Working-tree change'} ({len(files)} {word} changed {against})",
|
|
2090
2198
|
"files": files,
|
|
2091
2199
|
}
|
|
2092
2200
|
|
|
2093
2201
|
|
|
2202
|
+
def branch_code_change(root, base, commit, request):
|
|
2203
|
+
code_change_base = request.get("codeChangeBase")
|
|
2204
|
+
if not isinstance(code_change_base, dict):
|
|
2205
|
+
return None
|
|
2206
|
+
sha, ref = code_change_base.get("sha"), code_change_base.get("ref")
|
|
2207
|
+
if not (
|
|
2208
|
+
isinstance(sha, str)
|
|
2209
|
+
and SHA.fullmatch(sha)
|
|
2210
|
+
and isinstance(ref, str)
|
|
2211
|
+
and BRANCH_NAME.fullmatch(ref)
|
|
2212
|
+
and quiet_git(root, "rev-parse", "--verify", "-q", f"{commit}^2") == sha
|
|
2213
|
+
):
|
|
2214
|
+
return None
|
|
2215
|
+
return snapshot_code_change(
|
|
2216
|
+
root, sha, commit, replay_name(request["args"]), f"vs {ref}", base
|
|
2217
|
+
)
|
|
2218
|
+
|
|
2219
|
+
|
|
2094
2220
|
def write_code_change(change):
|
|
2095
2221
|
handle, path = tempfile.mkstemp(
|
|
2096
2222
|
prefix="bitfab-code-change-",
|
|
@@ -2127,6 +2253,7 @@ def execute():
|
|
|
2127
2253
|
None
|
|
2128
2254
|
if explicit_change or base is None
|
|
2129
2255
|
else snapshot_code_change(root, base, commit, replay_name(request["args"]))
|
|
2256
|
+
or branch_code_change(root, base, commit, request)
|
|
2130
2257
|
)
|
|
2131
2258
|
run_environment = dict(environment)
|
|
2132
2259
|
if change:
|
package/dist/baml.cjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
const require_bamlPeer = require("./bamlPeer-BUoZgNxZ.cjs");
|
|
6
|
+
let _boundaryml_baml = require("@boundaryml/baml");
|
|
7
|
+
_boundaryml_baml = require_bamlPeer.__toESM(_boundaryml_baml, 1);
|
|
8
|
+
//#region src/bamlEntry.ts
|
|
9
|
+
require_bamlPeer.registerBamlModule(_boundaryml_baml);
|
|
10
|
+
//#endregion
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=baml.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baml.cjs","names":["registerBamlModule","baml"],"sources":["../src/bamlEntry.ts"],"sourcesContent":["import * as baml from \"@boundaryml/baml\"\nimport { registerBamlModule } from \"./bamlPeer.js\"\n\nregisterBamlModule(baml)\n"],"mappings":";;;;;;;;AAGAA,iBAAAA,mBAAmBC,gBAAI"}
|
package/dist/baml.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/baml.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/baml.js
ADDED
package/dist/baml.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baml.js","names":[],"sources":["../src/bamlEntry.ts"],"sourcesContent":["import * as baml from \"@boundaryml/baml\"\nimport { registerBamlModule } from \"./bamlPeer.js\"\n\nregisterBamlModule(baml)\n"],"mappings":";;;AAGA,mBAAmB,IAAI"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __exportAll = (all, no_symbols) => {
|
|
9
|
+
let target = {};
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
|
+
return target;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
19
|
+
key = keys[i];
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
21
|
+
get: ((k) => from[k]).bind(null, key),
|
|
22
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/optionalPeer.ts
|
|
33
|
+
function importOptionalPeer(specifierParts) {
|
|
34
|
+
return import(
|
|
35
|
+
/* webpackIgnore: true */
|
|
36
|
+
/* @vite-ignore */
|
|
37
|
+
specifierParts.join("/")
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/bamlPeer.ts
|
|
42
|
+
const BAML_MODULE_STORAGE_SYMBOL = Symbol.for("bitfab.bamlModule");
|
|
43
|
+
let importedBamlModule;
|
|
44
|
+
function registeredBamlModule() {
|
|
45
|
+
return globalThis[BAML_MODULE_STORAGE_SYMBOL];
|
|
46
|
+
}
|
|
47
|
+
function registerBamlModule(bamlModule) {
|
|
48
|
+
globalThis[BAML_MODULE_STORAGE_SYMBOL] = bamlModule;
|
|
49
|
+
}
|
|
50
|
+
async function loadBamlModule() {
|
|
51
|
+
const registered = registeredBamlModule();
|
|
52
|
+
if (registered) return registered;
|
|
53
|
+
importedBamlModule ?? (importedBamlModule = importOptionalPeer(["@boundaryml", "baml"]).catch(() => null));
|
|
54
|
+
return await importedBamlModule ?? registeredBamlModule() ?? null;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
Object.defineProperty(exports, "__exportAll", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function() {
|
|
60
|
+
return __exportAll;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(exports, "__toESM", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function() {
|
|
66
|
+
return __toESM;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(exports, "importOptionalPeer", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function() {
|
|
72
|
+
return importOptionalPeer;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(exports, "loadBamlModule", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function() {
|
|
78
|
+
return loadBamlModule;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(exports, "registerBamlModule", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function() {
|
|
84
|
+
return registerBamlModule;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=bamlPeer-BUoZgNxZ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bamlPeer-BUoZgNxZ.cjs","names":[],"sources":["../src/optionalPeer.ts","../src/bamlPeer.ts"],"sourcesContent":["/**\n * Import an OPTIONAL peer dependency without breaking a consumer's bundler.\n *\n * Optional peers (declared in this package's `peerDependenciesMeta` with\n * `optional: true` - e.g. `@openai/agents`, `@boundaryml/baml`) are absent by\n * design for most consumers: someone who only uses the Vercel AI integration\n * never installs `@openai/agents`, and someone who never calls `Bitfab.call()`\n * never installs `@boundaryml/baml`.\n *\n * A plain `import(\"@openai/agents\")` leaves a static, literal specifier in the\n * built SDK. A consumer's bundler (webpack, Turbopack, Vite, Rollup, esbuild)\n * statically analyses that specifier and tries to resolve it at *build* time,\n * failing the whole build with \"Module not found: Can't resolve\n * '@openai/agents'\" even though that code path never runs for that consumer.\n * Wrapping the import in try/catch is not enough: only webpack >= 5.90.2 treats\n * that as optional, and Turbopack/Vite/older webpack do not.\n *\n * The robust, bundler-agnostic fix is to keep the specifier out of static\n * analysis entirely. The caller passes the specifier as parts that are joined\n * at runtime, so no bundler can see a literal module name to resolve. The\n * `webpackIgnore` / `@vite-ignore` magic comments are belt-and-suspenders for\n * bundlers that still inspect the (now non-literal) request. This mirrors the\n * technique already used for `node:async_hooks` in `asyncStorage.ts`.\n *\n * The import stays a native runtime `import()`: it resolves from `node_modules`\n * when the peer IS installed, and throws an ordinary module-not-found error\n * only when the feature is actually used without its peer installed - which is\n * the correct behaviour (the caller opted into an integration whose peer they\n * chose not to install).\n *\n * @param specifierParts - The package specifier split so it is reconstructed at\n * runtime, never appearing as a literal (e.g. `[\"@openai\", \"agents\"]` ->\n * `\"@openai/agents\"`).\n */\nexport function importOptionalPeer<T = unknown>(\n specifierParts: readonly string[],\n): Promise<T> {\n // Reconstructed at runtime so no bundler sees a literal specifier to resolve.\n const specifier = specifierParts.join(\"/\")\n return import(\n /* webpackIgnore: true */ /* @vite-ignore */ specifier\n ) as Promise<T>\n}\n","import { importOptionalPeer } from \"./optionalPeer.js\"\n\nexport type BamlModule = typeof import(\"@boundaryml/baml\")\n\nconst BAML_MODULE_STORAGE_SYMBOL = Symbol.for(\"bitfab.bamlModule\")\n\nlet importedBamlModule: Promise<BamlModule | null> | undefined\n\nfunction registeredBamlModule(): BamlModule | undefined {\n return (globalThis as Record<symbol, BamlModule | undefined>)[\n BAML_MODULE_STORAGE_SYMBOL\n ]\n}\n\nexport function registerBamlModule(bamlModule: BamlModule): void {\n ;(globalThis as Record<symbol, BamlModule | undefined>)[\n BAML_MODULE_STORAGE_SYMBOL\n ] = bamlModule\n}\n\nexport async function loadBamlModule(): Promise<BamlModule | null> {\n const registered = registeredBamlModule()\n if (registered) {\n return registered\n }\n importedBamlModule ??= importOptionalPeer<BamlModule>([\n \"@boundaryml\",\n \"baml\",\n ]).catch(() => null)\n return (await importedBamlModule) ?? registeredBamlModule() ?? null\n}\n\nexport function _resetBamlModule(): void {\n importedBamlModule = undefined\n delete (globalThis as Record<symbol, BamlModule | undefined>)[\n BAML_MODULE_STORAGE_SYMBOL\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,mBACd,gBACY;CAGZ,OAAO;;;EADW,eAAe,KAAK,GAEiB;;AAEzD;;;ACtCA,MAAM,6BAA6B,OAAO,IAAI,mBAAmB;AAEjE,IAAI;AAEJ,SAAS,uBAA+C;CACtD,OAAQ,WACN;AAEJ;AAEA,SAAgB,mBAAmB,YAA8B;CAC9D,WACC,8BACE;AACN;AAEA,eAAsB,iBAA6C;CACjE,MAAM,aAAa,qBAAqB;CACxC,IAAI,YACF,OAAO;CAET,uBAAA,qBAAuB,mBAA+B,CACpD,eACA,MACF,CAAC,CAAC,CAAC,YAAY,IAAI;CACnB,OAAQ,MAAM,sBAAuB,qBAAqB,KAAK;AACjE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/optionalPeer.ts
|
|
2
|
+
function importOptionalPeer(specifierParts) {
|
|
3
|
+
return import(
|
|
4
|
+
/* webpackIgnore: true */
|
|
5
|
+
/* @vite-ignore */
|
|
6
|
+
specifierParts.join("/")
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/bamlPeer.ts
|
|
11
|
+
const BAML_MODULE_STORAGE_SYMBOL = Symbol.for("bitfab.bamlModule");
|
|
12
|
+
let importedBamlModule;
|
|
13
|
+
function registeredBamlModule() {
|
|
14
|
+
return globalThis[BAML_MODULE_STORAGE_SYMBOL];
|
|
15
|
+
}
|
|
16
|
+
function registerBamlModule(bamlModule) {
|
|
17
|
+
globalThis[BAML_MODULE_STORAGE_SYMBOL] = bamlModule;
|
|
18
|
+
}
|
|
19
|
+
async function loadBamlModule() {
|
|
20
|
+
const registered = registeredBamlModule();
|
|
21
|
+
if (registered) return registered;
|
|
22
|
+
importedBamlModule ?? (importedBamlModule = importOptionalPeer(["@boundaryml", "baml"]).catch(() => null));
|
|
23
|
+
return await importedBamlModule ?? registeredBamlModule() ?? null;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { registerBamlModule as n, importOptionalPeer as r, loadBamlModule as t };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=bamlPeer-CIVwS68E.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bamlPeer-CIVwS68E.js","names":[],"sources":["../src/optionalPeer.ts","../src/bamlPeer.ts"],"sourcesContent":["/**\n * Import an OPTIONAL peer dependency without breaking a consumer's bundler.\n *\n * Optional peers (declared in this package's `peerDependenciesMeta` with\n * `optional: true` - e.g. `@openai/agents`, `@boundaryml/baml`) are absent by\n * design for most consumers: someone who only uses the Vercel AI integration\n * never installs `@openai/agents`, and someone who never calls `Bitfab.call()`\n * never installs `@boundaryml/baml`.\n *\n * A plain `import(\"@openai/agents\")` leaves a static, literal specifier in the\n * built SDK. A consumer's bundler (webpack, Turbopack, Vite, Rollup, esbuild)\n * statically analyses that specifier and tries to resolve it at *build* time,\n * failing the whole build with \"Module not found: Can't resolve\n * '@openai/agents'\" even though that code path never runs for that consumer.\n * Wrapping the import in try/catch is not enough: only webpack >= 5.90.2 treats\n * that as optional, and Turbopack/Vite/older webpack do not.\n *\n * The robust, bundler-agnostic fix is to keep the specifier out of static\n * analysis entirely. The caller passes the specifier as parts that are joined\n * at runtime, so no bundler can see a literal module name to resolve. The\n * `webpackIgnore` / `@vite-ignore` magic comments are belt-and-suspenders for\n * bundlers that still inspect the (now non-literal) request. This mirrors the\n * technique already used for `node:async_hooks` in `asyncStorage.ts`.\n *\n * The import stays a native runtime `import()`: it resolves from `node_modules`\n * when the peer IS installed, and throws an ordinary module-not-found error\n * only when the feature is actually used without its peer installed - which is\n * the correct behaviour (the caller opted into an integration whose peer they\n * chose not to install).\n *\n * @param specifierParts - The package specifier split so it is reconstructed at\n * runtime, never appearing as a literal (e.g. `[\"@openai\", \"agents\"]` ->\n * `\"@openai/agents\"`).\n */\nexport function importOptionalPeer<T = unknown>(\n specifierParts: readonly string[],\n): Promise<T> {\n // Reconstructed at runtime so no bundler sees a literal specifier to resolve.\n const specifier = specifierParts.join(\"/\")\n return import(\n /* webpackIgnore: true */ /* @vite-ignore */ specifier\n ) as Promise<T>\n}\n","import { importOptionalPeer } from \"./optionalPeer.js\"\n\nexport type BamlModule = typeof import(\"@boundaryml/baml\")\n\nconst BAML_MODULE_STORAGE_SYMBOL = Symbol.for(\"bitfab.bamlModule\")\n\nlet importedBamlModule: Promise<BamlModule | null> | undefined\n\nfunction registeredBamlModule(): BamlModule | undefined {\n return (globalThis as Record<symbol, BamlModule | undefined>)[\n BAML_MODULE_STORAGE_SYMBOL\n ]\n}\n\nexport function registerBamlModule(bamlModule: BamlModule): void {\n ;(globalThis as Record<symbol, BamlModule | undefined>)[\n BAML_MODULE_STORAGE_SYMBOL\n ] = bamlModule\n}\n\nexport async function loadBamlModule(): Promise<BamlModule | null> {\n const registered = registeredBamlModule()\n if (registered) {\n return registered\n }\n importedBamlModule ??= importOptionalPeer<BamlModule>([\n \"@boundaryml\",\n \"baml\",\n ]).catch(() => null)\n return (await importedBamlModule) ?? registeredBamlModule() ?? null\n}\n\nexport function _resetBamlModule(): void {\n importedBamlModule = undefined\n delete (globalThis as Record<symbol, BamlModule | undefined>)[\n BAML_MODULE_STORAGE_SYMBOL\n ]\n}\n"],"mappings":";AAkCA,SAAgB,mBACd,gBACY;CAGZ,OAAO;;;EADW,eAAe,KAAK,GAEiB;;AAEzD;;;ACtCA,MAAM,6BAA6B,OAAO,IAAI,mBAAmB;AAEjE,IAAI;AAEJ,SAAS,uBAA+C;CACtD,OAAQ,WACN;AAEJ;AAEA,SAAgB,mBAAmB,YAA8B;CAC9D,WACC,8BACE;AACN;AAEA,eAAsB,iBAA6C;CACjE,MAAM,aAAa,qBAAqB;CACxC,IAAI,YACF,OAAO;CAET,uBAAA,qBAAuB,mBAA+B,CACpD,eACA,MACF,CAAC,CAAC,CAAC,YAAY,IAAI;CACnB,OAAQ,MAAM,sBAAuB,qBAAqB,KAAK;AACjE"}
|
|
@@ -5,7 +5,7 @@ import { ExportResultCode } from "@opentelemetry/core";
|
|
|
5
5
|
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
6
6
|
import { AlwaysOnSampler, BasicTracerProvider, BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
7
7
|
//#region src/version.generated.ts
|
|
8
|
-
const __version__ = "0.65.
|
|
8
|
+
const __version__ = "0.65.9";
|
|
9
9
|
const __packageName__ = "@bitfab/sdk";
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/traceCompletion.ts
|
|
@@ -2160,4 +2160,4 @@ function experimentIdWireFields(experimentId) {
|
|
|
2160
2160
|
//#endregion
|
|
2161
2161
|
export { readEnv as C, MixedTracingError as S, getReplayContext as _, http_exports as a, gitRunner as b, recordCallerTraceMetadata as c, DECLARED_NODE_FIELD as d, ROOT_TRACE_FUNCTION_KEY_FIELD as f, MAX_COMPRESSIBLE_SPAN_CARRIER_BYTES as g, makeSpanOrigin as h, flushTraces as i, retireTraceMetadata as l, isFrameworkInstrumentation as m, SPAN_TYPES as n, unrefTimer as o, SimulationPlan as p, experimentIdWireFields as r, callerTraceMetadata as s, HttpClient as t, CONTENT_OFF_KEY as u, replayContextReady as v, __version__ as w, BitfabError as x, runWithReplayContext as y };
|
|
2162
2162
|
|
|
2163
|
-
//# sourceMappingURL=http-
|
|
2163
|
+
//# sourceMappingURL=http-DUDL3FGE.js.map
|