@xbbg/langgraph 1.2.6 → 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/LICENSE +190 -190
- package/README.md +234 -182
- package/dist/index.d.ts +25 -2
- package/dist/index.js +1012 -866
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -1,182 +1,234 @@
|
|
|
1
|
-
# @xbbg/langgraph
|
|
2
|
-
|
|
3
|
-
LangChain/LangGraph-compatible Bloomberg tools backed by [`@xbbg/core`](../js-xbbg/README.md).
|
|
4
|
-
|
|
5
|
-
This package is a reusable tool adapter. It is not a chat app, HTTP server, MCP server, browser package, or agent framework.
|
|
6
|
-
|
|
7
|
-
## Prerequisites
|
|
8
|
-
|
|
9
|
-
Bloomberg connectivity is still provided by `@xbbg/core`: an installed Bloomberg Terminal/Desktop API, B-PIPE, SAPI, or ZFP setup plus Bloomberg SDK runtime libraries must be available on the server running the tools.
|
|
10
|
-
|
|
11
|
-
## Install
|
|
12
|
-
|
|
13
|
-
Tool package only:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install @xbbg/langgraph @xbbg/core @langchain/core
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
LangGraph app:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm install @xbbg/langgraph @xbbg/core @langchain/core @langchain/langgraph
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Current LangChain agent app:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
npm install @xbbg/langgraph @xbbg/core @langchain/core langchain
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Agent guidance
|
|
32
|
-
|
|
33
|
-
Append the exported instructions to your system prompt:
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
import { BLOOMBERG_TOOL_INSTRUCTIONS } from "@xbbg/langgraph";
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
The instructions tell the model to ask clarifying questions for ambiguous tickers, fields, date ranges, currencies, periodicity, overrides, or universes; request `/isin/{isin}` for ISIN identifiers and `/cusip/{cusip}` for CUSIPs; use `xbbg_bflds` for unknown fields; prefer finite recipe tools for BEQS/YAS/universe workflows; use bounded snapshot tools instead of open subscriptions; keep requests bounded; and report empty, truncated, or errored responses directly.
|
|
40
|
-
|
|
41
|
-
## LangChain `createAgent` example
|
|
42
|
-
|
|
43
|
-
```ts
|
|
44
|
-
import { createAgent } from "langchain";
|
|
45
|
-
import { ChatOpenAI } from "@langchain/openai";
|
|
46
|
-
import { createAllBloombergTools, BLOOMBERG_TOOL_INSTRUCTIONS } from "@xbbg/langgraph";
|
|
47
|
-
|
|
48
|
-
const tools = createAllBloombergTools({
|
|
49
|
-
maxSecurities: 10,
|
|
50
|
-
maxFields: 10,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const agent = createAgent({
|
|
54
|
-
model: new ChatOpenAI({ model: "gpt-4.1" }),
|
|
55
|
-
tools,
|
|
56
|
-
systemPrompt: BLOOMBERG_TOOL_INSTRUCTIONS,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const result = await agent.invoke({
|
|
60
|
-
messages: [{ role: "user", content: "Get
|
|
61
|
-
});
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## LangGraph example
|
|
65
|
-
|
|
66
|
-
`createReactAgent` from `@langchain/langgraph/prebuilt` is deprecated upstream in favor of `createAgent` from `langchain`, but it is still common in LangGraph examples and accepts these tools because they are normal LangChain tools.
|
|
67
|
-
|
|
68
|
-
```ts
|
|
69
|
-
import { createReactAgent } from "@langchain/langgraph/prebuilt";
|
|
70
|
-
import { ChatOpenAI } from "@langchain/openai";
|
|
71
|
-
import { createBloombergTools, BLOOMBERG_TOOL_INSTRUCTIONS } from "@xbbg/langgraph";
|
|
72
|
-
|
|
73
|
-
const agent = createReactAgent({
|
|
74
|
-
llm: new ChatOpenAI({ model: "gpt-4.1" }),
|
|
75
|
-
tools: createBloombergTools({ maxSecurities: 5, maxFields: 5 }),
|
|
76
|
-
prompt: BLOOMBERG_TOOL_INSTRUCTIONS,
|
|
77
|
-
});
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
For custom graphs,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
- `
|
|
126
|
-
- `
|
|
127
|
-
- `
|
|
128
|
-
- `
|
|
129
|
-
- `
|
|
130
|
-
- `
|
|
131
|
-
- `
|
|
132
|
-
- `
|
|
133
|
-
- `
|
|
134
|
-
- `
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
import { createBloombergTools } from "@xbbg/langgraph";
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
const
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
- `
|
|
162
|
-
- `
|
|
163
|
-
- `
|
|
164
|
-
- `
|
|
165
|
-
- `
|
|
166
|
-
- `
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
1
|
+
# @xbbg/langgraph
|
|
2
|
+
|
|
3
|
+
LangChain/LangGraph-compatible Bloomberg tools backed by [`@xbbg/core`](../js-xbbg/README.md).
|
|
4
|
+
|
|
5
|
+
This package is a reusable tool adapter. It is not a chat app, HTTP server, MCP server, browser package, or agent framework.
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
Bloomberg connectivity is still provided by `@xbbg/core`: an installed Bloomberg Terminal/Desktop API, B-PIPE, SAPI, or ZFP setup plus Bloomberg SDK runtime libraries must be available on the server running the tools.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
Tool package only:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @xbbg/langgraph @xbbg/core @langchain/core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
LangGraph app:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @xbbg/langgraph @xbbg/core @langchain/core @langchain/langgraph @langchain/openai
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Current LangChain agent app:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @xbbg/langgraph @xbbg/core @langchain/core langchain @langchain/openai
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Agent guidance
|
|
32
|
+
|
|
33
|
+
Append the exported instructions to your system prompt:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { BLOOMBERG_TOOL_INSTRUCTIONS } from "@xbbg/langgraph";
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The instructions tell the model to ask clarifying questions for ambiguous tickers, fields, date ranges, currencies, periodicity, overrides, or universes; request `/isin/{isin}` for ISIN identifiers and `/cusip/{cusip}` for CUSIPs; use `xbbg_bflds` for unknown fields; prefer finite recipe tools for BEQS/YAS/universe workflows; use bounded snapshot tools instead of open subscriptions; keep requests bounded; and report empty, truncated, or errored responses directly.
|
|
40
|
+
|
|
41
|
+
## LangChain `createAgent` example
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { createAgent } from "langchain";
|
|
45
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
46
|
+
import { createAllBloombergTools, BLOOMBERG_TOOL_INSTRUCTIONS } from "@xbbg/langgraph";
|
|
47
|
+
|
|
48
|
+
const tools = createAllBloombergTools({
|
|
49
|
+
maxSecurities: 10,
|
|
50
|
+
maxFields: 10,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const agent = createAgent({
|
|
54
|
+
model: new ChatOpenAI({ model: "gpt-4.1" }),
|
|
55
|
+
tools,
|
|
56
|
+
systemPrompt: BLOOMBERG_TOOL_INSTRUCTIONS,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const result = await agent.invoke({
|
|
60
|
+
messages: [{ role: "user", content: "Get <FIELD> for <TICKER> <MARKET_SECTOR>." }],
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## LangGraph example
|
|
65
|
+
|
|
66
|
+
`createReactAgent` from `@langchain/langgraph/prebuilt` is deprecated upstream in favor of `createAgent` from `langchain`, but it is still common in LangGraph examples and accepts these tools because they are normal LangChain tools.
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { createReactAgent } from "@langchain/langgraph/prebuilt";
|
|
70
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
71
|
+
import { createBloombergTools, BLOOMBERG_TOOL_INSTRUCTIONS } from "@xbbg/langgraph";
|
|
72
|
+
|
|
73
|
+
const agent = createReactAgent({
|
|
74
|
+
llm: new ChatOpenAI({ model: "gpt-4.1" }),
|
|
75
|
+
tools: createBloombergTools({ maxSecurities: 5, maxFields: 5 }),
|
|
76
|
+
prompt: BLOOMBERG_TOOL_INSTRUCTIONS,
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
For custom graphs, bind the tools to your model and route tool calls through LangGraph's `ToolNode`:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { AIMessage } from "@langchain/core/messages";
|
|
84
|
+
import { END, MessagesAnnotation, START, StateGraph } from "@langchain/langgraph";
|
|
85
|
+
import { ToolNode } from "@langchain/langgraph/prebuilt";
|
|
86
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
87
|
+
import { createBloombergTools, BLOOMBERG_TOOL_INSTRUCTIONS } from "@xbbg/langgraph";
|
|
88
|
+
|
|
89
|
+
const tools = createBloombergTools({ maxSecurities: 5, maxFields: 5 });
|
|
90
|
+
const model = new ChatOpenAI({ model: "gpt-4.1" }).bindTools(tools);
|
|
91
|
+
const toolNode = new ToolNode(tools);
|
|
92
|
+
|
|
93
|
+
const callModel = async (state: typeof MessagesAnnotation.State) => ({
|
|
94
|
+
messages: [
|
|
95
|
+
await model.invoke([
|
|
96
|
+
{ role: "system", content: BLOOMBERG_TOOL_INSTRUCTIONS },
|
|
97
|
+
...state.messages,
|
|
98
|
+
]),
|
|
99
|
+
],
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const route = (state: typeof MessagesAnnotation.State) => {
|
|
103
|
+
const last = state.messages.at(-1);
|
|
104
|
+
return last instanceof AIMessage && last.tool_calls?.length ? "tools" : END;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const graph = new StateGraph(MessagesAnnotation)
|
|
108
|
+
.addNode("model", callModel)
|
|
109
|
+
.addNode("tools", toolNode)
|
|
110
|
+
.addEdge(START, "model")
|
|
111
|
+
.addConditionalEdges("model", route)
|
|
112
|
+
.addEdge("tools", "model")
|
|
113
|
+
.compile();
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
All tools use LangChain `responseFormat: "content_and_artifact"`. In `ToolNode`, the tool message content starts with a compact summary and then includes bounded model-readable JSON; `artifact` contains the structured bounded envelope for application code.
|
|
117
|
+
|
|
118
|
+
## Tool factories
|
|
119
|
+
|
|
120
|
+
Core Bloomberg request tools:
|
|
121
|
+
|
|
122
|
+
- `xbbg_bdp` - reference/current fields for a bounded securities list and explicit fields list.
|
|
123
|
+
- `xbbg_bdh` - historical time series; requires explicit `start` and `end`.
|
|
124
|
+
- `xbbg_bds` - one Bloomberg bulk/table field.
|
|
125
|
+
- `xbbg_bdib` - intraday bars; requires explicit `start`, `end`, and `interval`.
|
|
126
|
+
- `xbbg_bdtick` - intraday ticks; requires explicit `start`, `end`, and event types when the default stream is not intended.
|
|
127
|
+
- `xbbg_bql` - BQL expressions only.
|
|
128
|
+
- `xbbg_bsrch` - Bloomberg search/grid requests, not normal security lookup.
|
|
129
|
+
- `xbbg_bqr` - Bloomberg Quote Request / fixed-income dealer quotes; prefer identifiers such as `/isin/<ISIN>@<QUOTE_SOURCE> <MARKET_SECTOR>`.
|
|
130
|
+
- `xbbg_bflds` - field metadata/search; use first for uncertain mnemonics.
|
|
131
|
+
- `xbbg_beqs` - named Bloomberg BEQS equity screens.
|
|
132
|
+
- `xbbg_yas` - fixed-income YAS recipe fields for yield, duration, spread, benchmark, or price analytics.
|
|
133
|
+
- `xbbg_preferreds` - preferred stock discovery for one equity ticker.
|
|
134
|
+
- `xbbg_corporate_bonds` - corporate bond universe query for one issuer/company ticker.
|
|
135
|
+
- `xbbg_index_members` - index constituents through the core index recipe.
|
|
136
|
+
- `xbbg_resolve_isins` - raw ISIN-to-security resolution; pass raw ISIN strings to this recipe only.
|
|
137
|
+
- `xbbg_issuer_isins` - issuer/bond ISIN workflow starting from known bond ISIN strings.
|
|
138
|
+
- `xbbg_etf_holdings` - ETF holdings for one ETF ticker.
|
|
139
|
+
- `xbbg_stream_snapshot` - bounded `//blp/mktdata` live observation that always unsubscribes.
|
|
140
|
+
- `xbbg_mktbar_snapshot` - bounded `//blp/mktbar` live bar observation for one ticker.
|
|
141
|
+
- `xbbg_depth_snapshot` - bounded `//blp/mktdepthdata` market-depth observation for one ticker.
|
|
142
|
+
|
|
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
|
+
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
|
+
|
|
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
|
+
|
|
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
|
+
|
|
150
|
+
```ts
|
|
151
|
+
import { createBloombergTools, createBdpTool } from "@xbbg/langgraph";
|
|
152
|
+
|
|
153
|
+
const tools = createBloombergTools();
|
|
154
|
+
const bdpOnly = createBdpTool({ maxSecurities: 3 });
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Extension helper tools:
|
|
158
|
+
|
|
159
|
+
- `xbbg_ext_ticker` - ticker hygiene before live requests: parse, normalize lists, filter equity tickers, check specific contracts, and validate generic futures tickers.
|
|
160
|
+
- `xbbg_ext_futures` - futures construction and selection: month-code lookup, build a specific contract, generate candidates from a generic, rank contracts, filter by cycle, and filter valid contracts for a date.
|
|
161
|
+
- `xbbg_ext_cdx` - CDX workflows: parse CDX tickers, roll to previous series, resolve generic to specific series, and run predefined CDX info/pricing/risk field bundles.
|
|
162
|
+
- `xbbg_ext_currency` - currency planning: build FX pair metadata, test same-currency requests, and identify currencies needing conversion to a target.
|
|
163
|
+
- `xbbg_ext_bql_builder` - BQL query builders for preferred stocks, corporate bonds, and ETF holdings; prefer these over hand-writing those query shapes.
|
|
164
|
+
- `xbbg_ext_market_session` - exchange sessions and timezones: derive sessions, infer timezone, convert local session times to UTC, fetch market rules, compute turnover/BQR default ranges, and inspect exchange overrides.
|
|
165
|
+
- `xbbg_ext_yas_overrides` - build flat YAS override maps for lower-level fixed-income BDP workflows. Prefer `xbbg_yas` when you want the actual YAS recipe result.
|
|
166
|
+
- `xbbg_ext_constants` - static constants and formatting helpers for dates, futures months, dividend types, and ETF/dividend columns.
|
|
167
|
+
- `xbbg_ext_columns` - rename helpers for dividend, ETF, and earnings-shaped Bloomberg responses.
|
|
168
|
+
- `xbbg_ext_calculate` - small numeric helper for level percentage calculations.
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
import { createBloombergExtTools, createAllBloombergTools } from "@xbbg/langgraph";
|
|
172
|
+
|
|
173
|
+
const helperTools = createBloombergExtTools();
|
|
174
|
+
const allTools = createAllBloombergTools({
|
|
175
|
+
disabledTools: ["xbbg_bql", "xbbg_bsrch"],
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Engine handling
|
|
180
|
+
|
|
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
|
+
|
|
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
|
+
|
|
185
|
+
```ts
|
|
186
|
+
import * as xbbg from "@xbbg/core";
|
|
187
|
+
import { createBloombergTools } from "@xbbg/langgraph";
|
|
188
|
+
|
|
189
|
+
const engine = await xbbg.connect({ host: "localhost", port: 8194 });
|
|
190
|
+
const tools = createBloombergTools({ engine });
|
|
191
|
+
```
|
|
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
|
+
|
|
197
|
+
## Limits and outputs
|
|
198
|
+
|
|
199
|
+
Defaults:
|
|
200
|
+
|
|
201
|
+
- `maxSecurities = 25`
|
|
202
|
+
- `maxFields = 25`
|
|
203
|
+
- `maxRows = 500`
|
|
204
|
+
- `maxStringChars = 2000`
|
|
205
|
+
- `maxStreamUpdates = 10`
|
|
206
|
+
- `maxStreamWaitMs = 15000`
|
|
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
|
+
|
|
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:
|
|
215
|
+
|
|
216
|
+
```text
|
|
217
|
+
xbbg_bdp: 1 row; truncated=false
|
|
218
|
+
{"tool":"xbbg_bdp","rowCount":1,"truncated":false,"data":[{"security":"<TICKER> <MARKET_SECTOR>","field":"<FIELD>","value":"<VALUE>"}]}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
The artifact is the same bounded structured envelope for application code:
|
|
222
|
+
|
|
223
|
+
```json
|
|
224
|
+
{
|
|
225
|
+
"tool": "xbbg_bdp",
|
|
226
|
+
"rowCount": 1,
|
|
227
|
+
"truncated": false,
|
|
228
|
+
"data": [{ "security": "<TICKER> <MARKET_SECTOR>", "field": "<FIELD>", "value": "<VALUE>" }]
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
When invoking tools outside an agent graph and you need the artifact, invoke with a tool-call id (or use LangGraph `ToolNode`) so LangChain returns a `ToolMessage` with `artifact`.
|
|
233
|
+
|
|
234
|
+
Use smaller factories or `disabledTools` when broad BQL/search helpers are not appropriate for a deployment.
|
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 };
|