@xbbg/langgraph 1.2.7 → 1.3.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/README.md +14 -2
- package/dist/index.d.ts +25 -2
- package/dist/index.js +667 -645
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -140,12 +140,12 @@ Core Bloomberg request tools:
|
|
|
140
140
|
- `xbbg_mktbar_snapshot` - bounded `//blp/mktbar` live bar observation for one ticker.
|
|
141
141
|
- `xbbg_depth_snapshot` - bounded `//blp/mktdepthdata` market-depth observation for one ticker.
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
Securities are passed through in the form the user supplied them: Bloomberg tickers as `<TICKER> <MARKET_SECTOR>` (for example `<TICKER> <EXCHANGE> Equity`, `<INDEX_TICKER> Index`, `<CCY_PAIR> Curncy`), raw ISINs as `/isin/<ISIN>`, raw CUSIPs as `/cusip/<CUSIP>`. The market sector ending is Bloomberg's yellow key — `Equity`, `Index`, `Curncy`, `Comdty`, `Corp`, `Govt`, `Muni`, `Mtge`, `M-Mkt`, or `Pfd` (preferred securities) — and request tools pass it through to Bloomberg unvalidated. The agent guidance and every securities/ticker field description instruct the model that the ticker format is a template, not authorization to construct one — identifiers are never converted into guessed tickers; `xbbg_resolve_isins` exists for explicit resolution. Note `xbbg_ext_ticker`'s `parse_ticker` is narrower than the request tools: it parses generic futures-style tickers only (`Index`/`Curncy`/`Comdty`/`Corp`, or `<ROOT><N> <EXCHANGE> Equity`) and rejects other sectors.
|
|
144
144
|
BQL is passed as one complete expression string. Use placeholder shapes such as `get(<FIELD>) for('<TICKER> <MARKET_SECTOR>')`, `get(<FIELD_1>, <FIELD_2>) for(['<TICKER_1> <MARKET_SECTOR>', '<TICKER_2> <MARKET_SECTOR>'])`, `get(<FIELD>, <WEIGHT_FIELD>) for(holdings('<ETF_TICKER> <MARKET_SECTOR>'))`, or `get(<FIELD>) for(members('<INDEX_TICKER> <MARKET_SECTOR>')) with(...)`. Prefer `xbbg_bdp`/`xbbg_bdh` for simple reference or historical requests.
|
|
145
145
|
|
|
146
146
|
Dealer quote / BQR workflows in xbbg use fixed-income identifiers with a quote source, for example `/isin/<ISIN>@<QUOTE_SOURCE> <MARKET_SECTOR>`; use `xbbg_bqr` for that workflow and `xbbg_bdtick` for raw intraday ticks.
|
|
147
147
|
|
|
148
|
-
Streaming surfaces are intentionally exposed only as bounded snapshot tools. Each snapshot requires `maxUpdates`, applies the configured `maxStreamUpdates`/`maxStreamWaitMs` caps, stops on count, timeout, or stream completion, and calls `unsubscribe(false)` unless `drain: true` is explicitly provided. The package does not expose open-ended async subscription iterators as agent tools.
|
|
148
|
+
Streaming surfaces are intentionally exposed only as bounded snapshot tools. Each snapshot requires `maxUpdates`, applies the configured `maxStreamUpdates`/`maxStreamWaitMs` caps, stops on count, timeout, or stream completion, and calls `unsubscribe(false)` unless `drain: true` is explicitly provided. The package does not expose open-ended async subscription iterators as agent tools. If collection succeeds but releasing the subscription fails, the snapshot result still returns the collected updates and reports the failure in an `unsubscribeError` field instead of discarding data.
|
|
149
149
|
|
|
150
150
|
```ts
|
|
151
151
|
import { createBloombergTools, createBdpTool } from "@xbbg/langgraph";
|
|
@@ -180,6 +180,8 @@ const allTools = createAllBloombergTools({
|
|
|
180
180
|
|
|
181
181
|
By default the first tool invocation lazily imports `@xbbg/core`, calls `connect(engineConfig)`, and reuses the resulting engine across the tool set. Parallel LangGraph tool calls share the same in-flight initialization promise.
|
|
182
182
|
|
|
183
|
+
Lazily connected engines get a hard per-request timeout (`DEFAULT_ENGINE_REQUEST_TIMEOUT_MS`, 60s) because `@xbbg/core` disables request timeouts by default, which would let a wedged Terminal session hang tool calls forever. Pass `engineConfig: { requestTimeoutMs: ... }` to change it, or `0` to disable. A user-supplied `engine` is used as-is — its configuration and lifecycle (including disconnect) stay with the caller.
|
|
184
|
+
|
|
183
185
|
```ts
|
|
184
186
|
import * as xbbg from "@xbbg/core";
|
|
185
187
|
import { createBloombergTools } from "@xbbg/langgraph";
|
|
@@ -188,6 +190,10 @@ const engine = await xbbg.connect({ host: "localhost", port: 8194 });
|
|
|
188
190
|
const tools = createBloombergTools({ engine });
|
|
189
191
|
```
|
|
190
192
|
|
|
193
|
+
### Cancellation
|
|
194
|
+
|
|
195
|
+
Tools honor the LangChain/LangGraph `AbortSignal` (`graph.invoke(input, { signal })`): an aborted call rejects immediately, already-cancelled calls never start Bloomberg work, and snapshot tools stop collecting and unsubscribe right away (skipping `drain`) instead of running out their timeout. In-flight Bloomberg request/response calls cannot be cancelled mid-flight; they are bounded by the engine request timeout above.
|
|
196
|
+
|
|
191
197
|
## Limits and outputs
|
|
192
198
|
|
|
193
199
|
Defaults:
|
|
@@ -199,6 +205,12 @@ Defaults:
|
|
|
199
205
|
- `maxStreamUpdates = 10`
|
|
200
206
|
- `maxStreamWaitMs = 15000`
|
|
201
207
|
|
|
208
|
+
Date inputs accept `YYYY-MM-DD` or `YYYYMMDD` strings, integer `YYYYMMDD` values (parsed as calendar dates), and epoch milliseconds; ambiguous numbers between those ranges and ambiguous `MM/DD/YYYY` strings are rejected with actionable schema errors. `Date` instances are deliberately not part of the wire contract: JSON tool calls cannot carry them and `z.date()` breaks JSON Schema conversion in zod v4.
|
|
209
|
+
|
|
210
|
+
Schemas only advertise parameters the engine accepts: `format` exists on `xbbg_bdp`/`xbbg_bdh` only, because the engine rejects it for BulkData (`xbbg_bds`), BQL, search, field-info, and BEQS output; a model-sent `format` on those tools is stripped rather than forwarded. The exported `toolParameterJsonSchema(tool)` returns the provider-ready `$ref`-free JSON Schema used in each tool's embedded provider definition.
|
|
211
|
+
|
|
212
|
+
Empty results are called out in the model-facing summary (`empty result; verify identifiers, fields, and date range before concluding no data exists`) so agents distinguish "no rows" from silent failure instead of inventing data.
|
|
213
|
+
|
|
202
214
|
Each tool uses `backend: "json"` for finite request results and LangChain `content_and_artifact` output. The model-facing content starts with a short summary and then includes bounded JSON data:
|
|
203
215
|
|
|
204
216
|
```text
|
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ interface BloombergToolsOptions {
|
|
|
24
24
|
}
|
|
25
25
|
interface NormalizedBloombergToolsOptions {
|
|
26
26
|
readonly engine?: XbbgEngineLike;
|
|
27
|
-
readonly engineConfig
|
|
27
|
+
readonly engineConfig: xbbg.EngineConfig;
|
|
28
28
|
readonly core?: XbbgCoreLike;
|
|
29
29
|
readonly maxSecurities: number;
|
|
30
30
|
readonly maxFields: number;
|
|
@@ -37,6 +37,13 @@ interface NormalizedBloombergToolsOptions {
|
|
|
37
37
|
readonly validateFields: boolean | undefined;
|
|
38
38
|
readonly disabledTools: ReadonlySet<BloombergToolName>;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Default hard per-request timeout applied to lazily connected engines.
|
|
42
|
+
* @xbbg/core disables request timeouts by default (`requestTimeoutMs: 0`),
|
|
43
|
+
* which would let a wedged Terminal session hang tool calls forever. An
|
|
44
|
+
* explicit `engineConfig.requestTimeoutMs` (including 0) always wins.
|
|
45
|
+
*/
|
|
46
|
+
declare const DEFAULT_ENGINE_REQUEST_TIMEOUT_MS = 60000;
|
|
40
47
|
|
|
41
48
|
type BloombergTool = StructuredToolInterface;
|
|
42
49
|
declare function createBdpTool(options?: BloombergToolsOptions): BloombergTool;
|
|
@@ -88,6 +95,22 @@ interface ToolEnvelope {
|
|
|
88
95
|
readonly data: unknown;
|
|
89
96
|
}
|
|
90
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Subset of the LangChain runnable config forwarded to tool functions.
|
|
100
|
+
* `signal` aborts the call: the LangChain wrapper rejects immediately, and
|
|
101
|
+
* Bloomberg tool functions use it to stop waiting and release subscriptions.
|
|
102
|
+
*/
|
|
103
|
+
interface ToolInvocationConfig {
|
|
104
|
+
readonly signal?: AbortSignal;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Provider-ready JSON Schema for a Bloomberg tool's input parameters, using
|
|
108
|
+
* the same conversion settings as the embedded provider tool definition
|
|
109
|
+
* ($ref-free, input-side of transforms). Exposed so consumers do not each
|
|
110
|
+
* reinvent zod -> JSON Schema conversion and sanitization.
|
|
111
|
+
*/
|
|
112
|
+
declare function toolParameterJsonSchema(toolInstance: StructuredToolInterface): Record<string, unknown>;
|
|
113
|
+
|
|
91
114
|
declare function createAllBloombergTools(options?: BloombergToolsOptions): BloombergTool[];
|
|
92
115
|
|
|
93
|
-
export { BLOOMBERG_EXT_TOOL_NAMES, BLOOMBERG_TOOL_INSTRUCTIONS, BLOOMBERG_TOOL_NAMES, type BloombergTool, type BloombergToolInstructionsOptions, type BloombergToolName, type BloombergToolsOptions, type NormalizedBloombergToolsOptions, type ToolEnvelope, createAllBloombergTools, createBdhTool, createBdibTool, createBdpTool, createBdsTool, createBdtickTool, createBeqsTool, createBfldsTool, createBloombergExtTools, createBloombergTools, createBqlTool, createBqrTool, createBsrchTool, createCorporateBondsTool, createDepthSnapshotTool, createEtfHoldingsTool, createExtBqlBuilderTool, createExtCalculateTool, createExtCdxTool, createExtColumnsTool, createExtConstantsTool, createExtCurrencyTool, createExtFuturesTool, createExtMarketSessionTool, createExtTickerTool, createExtYasOverridesTool, createIndexMembersTool, createIssuerIsinsTool, createMktbarSnapshotTool, createPreferredsTool, createResolveIsinsTool, createStreamSnapshotTool, createYasTool, getBloombergToolInstructions };
|
|
116
|
+
export { BLOOMBERG_EXT_TOOL_NAMES, BLOOMBERG_TOOL_INSTRUCTIONS, BLOOMBERG_TOOL_NAMES, type BloombergTool, type BloombergToolInstructionsOptions, type BloombergToolName, type BloombergToolsOptions, DEFAULT_ENGINE_REQUEST_TIMEOUT_MS, type NormalizedBloombergToolsOptions, type ToolEnvelope, type ToolInvocationConfig, createAllBloombergTools, createBdhTool, createBdibTool, createBdpTool, createBdsTool, createBdtickTool, createBeqsTool, createBfldsTool, createBloombergExtTools, createBloombergTools, createBqlTool, createBqrTool, createBsrchTool, createCorporateBondsTool, createDepthSnapshotTool, createEtfHoldingsTool, createExtBqlBuilderTool, createExtCalculateTool, createExtCdxTool, createExtColumnsTool, createExtConstantsTool, createExtCurrencyTool, createExtFuturesTool, createExtMarketSessionTool, createExtTickerTool, createExtYasOverridesTool, createIndexMembersTool, createIssuerIsinsTool, createMktbarSnapshotTool, createPreferredsTool, createResolveIsinsTool, createStreamSnapshotTool, createYasTool, getBloombergToolInstructions, toolParameterJsonSchema };
|