@bitfab/sdk 0.25.0 → 0.26.0
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-GQLNEYSU.js → chunk-GCAJN5I7.js} +97 -2
- package/dist/{chunk-GQLNEYSU.js.map → chunk-GCAJN5I7.js.map} +1 -1
- package/dist/index.cjs +96 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +88 -1
- package/dist/index.d.ts +88 -1
- package/dist/index.js +1 -1
- package/dist/node.cjs +96 -1
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +1 -1
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./chunk-26MUT4IP.js";
|
|
13
13
|
|
|
14
14
|
// src/version.generated.ts
|
|
15
|
-
var __version__ = "0.
|
|
15
|
+
var __version__ = "0.26.0";
|
|
16
16
|
|
|
17
17
|
// src/constants.ts
|
|
18
18
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -3497,10 +3497,105 @@ var BitfabFunction = class {
|
|
|
3497
3497
|
const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
|
|
3498
3498
|
return this.client.withSpan(this.traceFunctionKey, options, fn);
|
|
3499
3499
|
}
|
|
3500
|
+
/**
|
|
3501
|
+
* Get a Vercel AI SDK language-model middleware bound to this function's key.
|
|
3502
|
+
*
|
|
3503
|
+
* Equivalent to `client.getVercelAiMiddleware(key)` but reuses the key bound
|
|
3504
|
+
* on this handle, so an outer `withSpan` root and the middleware-traced model
|
|
3505
|
+
* calls share one key without repeating the string. With a matching key, the
|
|
3506
|
+
* outer span is the replayable root and the model-call spans nest beneath it.
|
|
3507
|
+
*
|
|
3508
|
+
* Nesting is captured when the model is called, so keep the
|
|
3509
|
+
* `generateText` / `streamText` call inside this handle's `withSpan`; the
|
|
3510
|
+
* middleware object itself can be created anywhere.
|
|
3511
|
+
*
|
|
3512
|
+
* ```typescript
|
|
3513
|
+
* const chatTurn = client.getFunction("chat-turn");
|
|
3514
|
+
* const runChatTurn = chatTurn.withSpan(
|
|
3515
|
+
* { type: "agent", finalize: finalizers.aiSdk },
|
|
3516
|
+
* (messages) => streamText({ model, messages }),
|
|
3517
|
+
* );
|
|
3518
|
+
* const model = wrapLanguageModel({
|
|
3519
|
+
* model: openai("gpt-4o"),
|
|
3520
|
+
* middleware: chatTurn.getVercelAiMiddleware(),
|
|
3521
|
+
* });
|
|
3522
|
+
* ```
|
|
3523
|
+
*
|
|
3524
|
+
* @returns A Vercel AI SDK middleware configured for this client and key
|
|
3525
|
+
*/
|
|
3526
|
+
getVercelAiMiddleware() {
|
|
3527
|
+
return this.client.getVercelAiMiddleware(this.traceFunctionKey);
|
|
3528
|
+
}
|
|
3529
|
+
/**
|
|
3530
|
+
* Get a Claude Agent SDK handler bound to this function's key.
|
|
3531
|
+
*
|
|
3532
|
+
* Equivalent to `client.getClaudeAgentHandler(key)` but reuses the key bound
|
|
3533
|
+
* on this handle, so an outer `withSpan` root and the handler share one key
|
|
3534
|
+
* without repeating the string. With a matching key, the outer span is the
|
|
3535
|
+
* replayable root and every handler span nests beneath it.
|
|
3536
|
+
*
|
|
3537
|
+
* Use the handler inside this handle's `withSpan` body so its spans capture
|
|
3538
|
+
* the enclosing root; framework calls made with no active span record their
|
|
3539
|
+
* own root instead.
|
|
3540
|
+
*
|
|
3541
|
+
* ```typescript
|
|
3542
|
+
* const pipeline = client.getFunction("my-agent");
|
|
3543
|
+
* const tracedRun = pipeline.withSpan({ type: "agent" }, async (prompt) => {
|
|
3544
|
+
* const handler = pipeline.getClaudeAgentHandler();
|
|
3545
|
+
* const options = handler.instrumentOptions({ model: "claude-sonnet-4-6" });
|
|
3546
|
+
* for await (const msg of handler.wrapQuery(query({ prompt, options }))) { ... }
|
|
3547
|
+
* });
|
|
3548
|
+
* ```
|
|
3549
|
+
*
|
|
3550
|
+
* @returns A Claude Agent SDK handler configured for this client and key
|
|
3551
|
+
*/
|
|
3552
|
+
getClaudeAgentHandler() {
|
|
3553
|
+
return this.client.getClaudeAgentHandler(this.traceFunctionKey);
|
|
3554
|
+
}
|
|
3555
|
+
/**
|
|
3556
|
+
* Get a LangGraph/LangChain callback handler bound to this function's key.
|
|
3557
|
+
*
|
|
3558
|
+
* Equivalent to `client.getLangGraphCallbackHandler(key)` but reuses the key
|
|
3559
|
+
* bound on this handle, so an outer `withSpan` root and the handler share one
|
|
3560
|
+
* key without repeating the string. With a matching key, the outer span is
|
|
3561
|
+
* the replayable root and the LangGraph spans nest beneath it.
|
|
3562
|
+
*
|
|
3563
|
+
* Use the handler inside this handle's `withSpan` body so its spans capture
|
|
3564
|
+
* the enclosing root; framework calls made with no active span record their
|
|
3565
|
+
* own root instead.
|
|
3566
|
+
*
|
|
3567
|
+
* ```typescript
|
|
3568
|
+
* const pipeline = client.getFunction("my-pipeline");
|
|
3569
|
+
* const tracedRun = pipeline.withSpan({ type: "agent" }, async (query) => {
|
|
3570
|
+
* const handler = pipeline.getLangGraphCallbackHandler();
|
|
3571
|
+
* return agent.invoke({ messages: [...] }, { callbacks: [handler] });
|
|
3572
|
+
* });
|
|
3573
|
+
* ```
|
|
3574
|
+
*
|
|
3575
|
+
* @returns A LangGraph/LangChain callback handler for this client and key
|
|
3576
|
+
*/
|
|
3577
|
+
getLangGraphCallbackHandler() {
|
|
3578
|
+
return this.client.getLangGraphCallbackHandler(this.traceFunctionKey);
|
|
3579
|
+
}
|
|
3580
|
+
/**
|
|
3581
|
+
* Alias of {@link getLangGraphCallbackHandler} — LangChain and LangGraph
|
|
3582
|
+
* share one callback system, so the same bound handler serves both.
|
|
3583
|
+
*
|
|
3584
|
+
* @returns A LangChain callback handler for this client and key
|
|
3585
|
+
*/
|
|
3586
|
+
getLangChainCallbackHandler() {
|
|
3587
|
+
return this.client.getLangChainCallbackHandler(this.traceFunctionKey);
|
|
3588
|
+
}
|
|
3500
3589
|
/**
|
|
3501
3590
|
* Wrap a BAML client method to automatically capture prompt and LLM metadata.
|
|
3502
3591
|
* Delegates to the parent client's wrapBAML method.
|
|
3503
3592
|
*
|
|
3593
|
+
* Unlike the other methods on this handle, `wrapBAML` does NOT use the bound
|
|
3594
|
+
* key: it opens no span of its own. It enriches the *current* span (via
|
|
3595
|
+
* `getCurrentSpan().setPrompt()` / `addContext()`), so call it inside a
|
|
3596
|
+
* function wrapped by this handle's `withSpan` — the bound key keys that
|
|
3597
|
+
* wrapper, and the BAML prompt/metadata attach to it.
|
|
3598
|
+
*
|
|
3504
3599
|
* @param methodOrClient - Either a BAML method (uses constructor bamlClient) or the BAML client instance
|
|
3505
3600
|
* @param maybeMethodOrOptions - The BAML method when the first argument is a client, or WrapBAMLOptions when the first argument is the method
|
|
3506
3601
|
* @param maybeOptions - WrapBAMLOptions when using the two-argument (client, method) form
|
|
@@ -3580,4 +3675,4 @@ export {
|
|
|
3580
3675
|
BitfabFunction,
|
|
3581
3676
|
finalizers
|
|
3582
3677
|
};
|
|
3583
|
-
//# sourceMappingURL=chunk-
|
|
3678
|
+
//# sourceMappingURL=chunk-GCAJN5I7.js.map
|