@xbbg/langgraph 1.4.3 → 1.4.4

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 CHANGED
@@ -130,6 +130,7 @@ Core Bloomberg request tools:
130
130
  - `xbbg_bds` - one Bloomberg bulk/table field.
131
131
  - `xbbg_bdib` - intraday bars; requires explicit `start`, `end`, and `interval`.
132
132
  - `xbbg_bdtick` - intraday ticks; requires explicit `start`, `end`, and event types when the default stream is not intended.
133
+ - `xbbg_check_entitlements` - checks a nonempty EID list against `//blp/refdata` or an explicitly supplied Bloomberg service.
133
134
  - `xbbg_bql` - BQL expressions only.
134
135
  - `xbbg_bsrch` - Bloomberg search/grid requests, not normal security lookup.
135
136
  - `xbbg_bqr` - Bloomberg Quote Request / fixed-income dealer quotes; prefer identifiers such as `/isin/<ISIN>@<QUOTE_SOURCE> <MARKET_SECTOR>`.
@@ -146,6 +147,30 @@ Core Bloomberg request tools:
146
147
  - `xbbg_mktbar_snapshot` - bounded `//blp/mktbar` live bar observation for one ticker.
147
148
  - `xbbg_depth_snapshot` - bounded `//blp/mktdepthdata` market-depth observation for one ticker.
148
149
 
150
+ ### Entitlement IDs
151
+
152
+ The `xbbg_bdp`, `xbbg_bds`, `xbbg_bdh`, `xbbg_bdib`, and `xbbg_bdtick` inputs accept `returnEids: true`. These map only to Bloomberg's EID-capable `ReferenceDataRequest` (including BDS), `HistoricalDataRequest`, `IntradayBarRequest`, and `IntradayTickRequest` operations.
153
+
154
+ When EIDs are requested, bounded tool artifacts retain result metadata alongside the bounded rows:
155
+
156
+ ```json
157
+ {
158
+ "data": {
159
+ "rows": [],
160
+ "eidData": { "<TICKER> <MARKET_SECTOR>": [101, 202] },
161
+ "metadata": { "xbbg.eid_data": "{\"<TICKER> <MARKET_SECTOR>\":[101,202]}" }
162
+ },
163
+ "rowCount": 0,
164
+ "truncated": false
165
+ }
166
+ ```
167
+
168
+ Row bounding does not discard `eidData`, `metadata`, `securityErrors`, or `fieldExceptions`. Pass the collected IDs to `xbbg_check_entitlements`:
169
+
170
+ ```json
171
+ { "eids": [101, 202], "service": "//blp/refdata" }
172
+ ```
173
+
149
174
  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.
150
175
  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.
151
176
 
package/dist/index.d.ts CHANGED
@@ -2,10 +2,28 @@ import * as xbbg from '@xbbg/core';
2
2
  import { StructuredToolInterface } from '@langchain/core/tools';
3
3
 
4
4
  type XbbgCoreModule = typeof xbbg;
5
- type XbbgEngineLike = Pick<Awaited<ReturnType<XbbgCoreModule["connect"]>>, "bdp" | "bdh" | "bds" | "bdib" | "bdtick" | "bql" | "bsrch" | "bqr" | "bflds" | "beqs" | "yas" | "preferreds" | "corporateBonds" | "indexMembers" | "resolveIsins" | "issuerIsins" | "etfHoldings" | "stream" | "mktbar" | "depth">;
6
- type XbbgCoreLike = Pick<XbbgCoreModule, "connect" | "ext">;
5
+ interface EntitlementReport {
6
+ readonly entitled: boolean;
7
+ readonly failedEids: readonly number[];
8
+ }
9
+ type CoreEngineMethods = Pick<Awaited<ReturnType<XbbgCoreModule["connect"]>>, "bdp" | "bdh" | "bds" | "bql" | "bsrch" | "bqr" | "bflds" | "beqs" | "yas" | "preferreds" | "corporateBonds" | "indexMembers" | "resolveIsins" | "issuerIsins" | "etfHoldings" | "stream" | "mktbar" | "depth">;
10
+ type XbbgEngineLike = {
11
+ readonly [Method in keyof CoreEngineMethods]: OmitThisParameter<CoreEngineMethods[Method]>;
12
+ } & {
13
+ readonly bdib: (ticker: string, options: xbbg.BdibOptions & {
14
+ readonly returnEids?: boolean;
15
+ }) => Promise<unknown>;
16
+ readonly bdtick: (ticker: string, options: xbbg.BdtickOptions & {
17
+ readonly returnEids?: boolean;
18
+ }) => Promise<unknown>;
19
+ readonly checkEntitlements: (service: string, eids: readonly number[]) => Promise<EntitlementReport>;
20
+ };
21
+ interface XbbgCoreLike {
22
+ readonly ext: XbbgCoreModule["ext"];
23
+ readonly connect: (config?: xbbg.EngineConfig) => Promise<XbbgEngineLike>;
24
+ }
7
25
 
8
- declare const BLOOMBERG_TOOL_NAMES: readonly ["xbbg_bdp", "xbbg_bdh", "xbbg_bds", "xbbg_bdib", "xbbg_bdtick", "xbbg_bql", "xbbg_bsrch", "xbbg_bqr", "xbbg_bflds", "xbbg_beqs", "xbbg_yas", "xbbg_preferreds", "xbbg_corporate_bonds", "xbbg_index_members", "xbbg_resolve_isins", "xbbg_issuer_isins", "xbbg_etf_holdings", "xbbg_stream_snapshot", "xbbg_mktbar_snapshot", "xbbg_depth_snapshot", "xbbg_ext_ticker", "xbbg_ext_futures", "xbbg_ext_cdx", "xbbg_ext_currency", "xbbg_ext_bql_builder", "xbbg_ext_chart_spec", "xbbg_ext_market_session", "xbbg_ext_yas_overrides", "xbbg_ext_constants", "xbbg_ext_columns", "xbbg_ext_calculate"];
26
+ declare const BLOOMBERG_TOOL_NAMES: readonly ["xbbg_bdp", "xbbg_bdh", "xbbg_bds", "xbbg_bdib", "xbbg_bdtick", "xbbg_check_entitlements", "xbbg_bql", "xbbg_bsrch", "xbbg_bqr", "xbbg_bflds", "xbbg_beqs", "xbbg_yas", "xbbg_preferreds", "xbbg_corporate_bonds", "xbbg_index_members", "xbbg_resolve_isins", "xbbg_issuer_isins", "xbbg_etf_holdings", "xbbg_stream_snapshot", "xbbg_mktbar_snapshot", "xbbg_depth_snapshot", "xbbg_ext_ticker", "xbbg_ext_futures", "xbbg_ext_cdx", "xbbg_ext_currency", "xbbg_ext_bql_builder", "xbbg_ext_chart_spec", "xbbg_ext_market_session", "xbbg_ext_yas_overrides", "xbbg_ext_constants", "xbbg_ext_columns", "xbbg_ext_calculate"];
9
27
  type BloombergToolName = (typeof BLOOMBERG_TOOL_NAMES)[number];
10
28
  interface BloombergToolsOptions {
11
29
  readonly engine?: XbbgEngineLike;
@@ -51,6 +69,7 @@ declare function createBdhTool(options?: BloombergToolsOptions): BloombergTool;
51
69
  declare function createBdsTool(options?: BloombergToolsOptions): BloombergTool;
52
70
  declare function createBdibTool(options?: BloombergToolsOptions): BloombergTool;
53
71
  declare function createBdtickTool(options?: BloombergToolsOptions): BloombergTool;
72
+ declare function createCheckEntitlementsTool(options?: BloombergToolsOptions): BloombergTool;
54
73
  declare function createBqlTool(options?: BloombergToolsOptions): BloombergTool;
55
74
  declare function createBsrchTool(options?: BloombergToolsOptions): BloombergTool;
56
75
  declare function createBqrTool(options?: BloombergToolsOptions): BloombergTool;
@@ -75,7 +94,7 @@ interface BloombergToolInstructionsOptions {
75
94
  }
76
95
  declare function getBloombergToolInstructions(options?: BloombergToolInstructionsOptions): string;
77
96
 
78
- declare const BLOOMBERG_EXT_TOOL_NAMES: readonly ("xbbg_bdp" | "xbbg_bdh" | "xbbg_bds" | "xbbg_bdib" | "xbbg_bdtick" | "xbbg_bql" | "xbbg_bsrch" | "xbbg_bqr" | "xbbg_bflds" | "xbbg_beqs" | "xbbg_yas" | "xbbg_preferreds" | "xbbg_corporate_bonds" | "xbbg_index_members" | "xbbg_resolve_isins" | "xbbg_issuer_isins" | "xbbg_etf_holdings" | "xbbg_stream_snapshot" | "xbbg_mktbar_snapshot" | "xbbg_depth_snapshot" | "xbbg_ext_ticker" | "xbbg_ext_futures" | "xbbg_ext_cdx" | "xbbg_ext_currency" | "xbbg_ext_bql_builder" | "xbbg_ext_chart_spec" | "xbbg_ext_market_session" | "xbbg_ext_yas_overrides" | "xbbg_ext_constants" | "xbbg_ext_columns" | "xbbg_ext_calculate")[];
97
+ declare const BLOOMBERG_EXT_TOOL_NAMES: readonly ("xbbg_bdp" | "xbbg_bdh" | "xbbg_bds" | "xbbg_bdib" | "xbbg_bdtick" | "xbbg_check_entitlements" | "xbbg_bql" | "xbbg_bsrch" | "xbbg_bqr" | "xbbg_bflds" | "xbbg_beqs" | "xbbg_yas" | "xbbg_preferreds" | "xbbg_corporate_bonds" | "xbbg_index_members" | "xbbg_resolve_isins" | "xbbg_issuer_isins" | "xbbg_etf_holdings" | "xbbg_stream_snapshot" | "xbbg_mktbar_snapshot" | "xbbg_depth_snapshot" | "xbbg_ext_ticker" | "xbbg_ext_futures" | "xbbg_ext_cdx" | "xbbg_ext_currency" | "xbbg_ext_bql_builder" | "xbbg_ext_chart_spec" | "xbbg_ext_market_session" | "xbbg_ext_yas_overrides" | "xbbg_ext_constants" | "xbbg_ext_columns" | "xbbg_ext_calculate")[];
79
98
  declare function createExtTickerTool(options?: BloombergToolsOptions): BloombergTool;
80
99
  declare function createExtFuturesTool(options?: BloombergToolsOptions): BloombergTool;
81
100
  declare function createExtCdxTool(options?: BloombergToolsOptions): BloombergTool;
@@ -176,4 +195,4 @@ interface ChartSpecOutput {
176
195
 
177
196
  declare function createAllBloombergTools(options?: BloombergToolsOptions): BloombergTool[];
178
197
 
179
- export { BLOOMBERG_EXT_TOOL_NAMES, BLOOMBERG_TOOL_INSTRUCTIONS, BLOOMBERG_TOOL_NAMES, type BloombergChartSource, type BloombergTool, type BloombergToolInstructionsOptions, type BloombergToolName, type BloombergToolsOptions, type ChartKind, type ChartRenderer, type ChartRow, type ChartScalar, type ChartSpecInput, type ChartSpecOutput, type ChartSpecSummary, DEFAULT_ENGINE_REQUEST_TIMEOUT_MS, type NormalizedBloombergToolsOptions, type ToolEnvelope, type ToolInvocationConfig, type VegaLiteSpec, createAllBloombergTools, createBdhTool, createBdibTool, createBdpTool, createBdsTool, createBdtickTool, createBeqsTool, createBfldsTool, createBloombergExtTools, createBloombergTools, createBqlTool, createBqrTool, createBsrchTool, createCorporateBondsTool, createDepthSnapshotTool, createEtfHoldingsTool, createExtBqlBuilderTool, createExtCalculateTool, createExtCdxTool, createExtChartSpecTool, createExtColumnsTool, createExtConstantsTool, createExtCurrencyTool, createExtFuturesTool, createExtMarketSessionTool, createExtTickerTool, createExtYasOverridesTool, createIndexMembersTool, createIssuerIsinsTool, createMktbarSnapshotTool, createPreferredsTool, createResolveIsinsTool, createStreamSnapshotTool, createYasTool, getBloombergToolInstructions, toolParameterJsonSchema };
198
+ export { BLOOMBERG_EXT_TOOL_NAMES, BLOOMBERG_TOOL_INSTRUCTIONS, BLOOMBERG_TOOL_NAMES, type BloombergChartSource, type BloombergTool, type BloombergToolInstructionsOptions, type BloombergToolName, type BloombergToolsOptions, type ChartKind, type ChartRenderer, type ChartRow, type ChartScalar, type ChartSpecInput, type ChartSpecOutput, type ChartSpecSummary, DEFAULT_ENGINE_REQUEST_TIMEOUT_MS, type NormalizedBloombergToolsOptions, type ToolEnvelope, type ToolInvocationConfig, type VegaLiteSpec, createAllBloombergTools, createBdhTool, createBdibTool, createBdpTool, createBdsTool, createBdtickTool, createBeqsTool, createBfldsTool, createBloombergExtTools, createBloombergTools, createBqlTool, createBqrTool, createBsrchTool, createCheckEntitlementsTool, createCorporateBondsTool, createDepthSnapshotTool, createEtfHoldingsTool, createExtBqlBuilderTool, createExtCalculateTool, createExtCdxTool, createExtChartSpecTool, createExtColumnsTool, createExtConstantsTool, createExtCurrencyTool, createExtFuturesTool, createExtMarketSessionTool, createExtTickerTool, createExtYasOverridesTool, createIndexMembersTool, createIssuerIsinsTool, createMktbarSnapshotTool, createPreferredsTool, createResolveIsinsTool, createStreamSnapshotTool, createYasTool, getBloombergToolInstructions, toolParameterJsonSchema };
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ var BLOOMBERG_TOOL_NAMES = [
31
31
  "xbbg_bds",
32
32
  "xbbg_bdib",
33
33
  "xbbg_bdtick",
34
+ "xbbg_check_entitlements",
34
35
  "xbbg_bql",
35
36
  "xbbg_bsrch",
36
37
  "xbbg_bqr",
@@ -178,6 +179,11 @@ function createCoreResolver(options = {}) {
178
179
 
179
180
  // src/result-limits.ts
180
181
  var MAX_RESULT_DEPTH = 32;
182
+ var MAX_ENTITLEMENT_EIDS = 1e4;
183
+ var MAX_BLOOMBERG_EID = 2147483647;
184
+ var MAX_EID_SECURITIES = 1e3;
185
+ var MAX_EID_SECURITY_NAME_BYTES = 65536;
186
+ var UTF8_ENCODER = new TextEncoder();
181
187
  function isPlainObject(value) {
182
188
  const prototype = Object.getPrototypeOf(value);
183
189
  return prototype === Object.prototype || prototype === null;
@@ -189,6 +195,97 @@ function truncateString(value, maxStringChars, state) {
189
195
  state.truncated = true;
190
196
  return `${value.slice(0, maxStringChars)}\u2026[truncated ${value.length - maxStringChars} chars]`;
191
197
  }
198
+ function arrayMetadata(value) {
199
+ const metadata = {};
200
+ for (const [key, entry] of Object.entries(value)) {
201
+ if (!/^(?:0|[1-9]\d*)$/u.test(key)) {
202
+ metadata[key] = entry;
203
+ }
204
+ }
205
+ return metadata;
206
+ }
207
+ function limitEidData(value, maxStringChars, state, depth, seen) {
208
+ if (typeof value !== "object" || value === null || !isPlainObject(value)) {
209
+ state.truncated = true;
210
+ return {
211
+ data: {},
212
+ truncation: {
213
+ invalidSecurityCount: 1,
214
+ omittedSecurityCount: 0,
215
+ retainedEidCount: 0,
216
+ retainedSecurityCount: 0,
217
+ securityCounts: [],
218
+ totalEidCount: 0,
219
+ totalSecurityCount: 1
220
+ }
221
+ };
222
+ }
223
+ const data = /* @__PURE__ */ Object.create(null);
224
+ const securityCounts = [];
225
+ const entries = Object.entries(value);
226
+ let retainedEidCount = 0;
227
+ let retainedSecurityCount = 0;
228
+ let retainedSecurityNameBytes = 0;
229
+ let totalEidCount = 0;
230
+ let invalidSecurityCount = 0;
231
+ for (const [security, eids] of entries) {
232
+ if (!Array.isArray(eids)) {
233
+ state.truncated = true;
234
+ invalidSecurityCount += 1;
235
+ continue;
236
+ }
237
+ let validEids = true;
238
+ for (let index = 0; index < eids.length; index += 1) {
239
+ const eid = eids[index];
240
+ if (!Object.hasOwn(eids, index) || typeof eid !== "number" || !Number.isInteger(eid) || eid <= 0 || eid > MAX_BLOOMBERG_EID) {
241
+ validEids = false;
242
+ break;
243
+ }
244
+ }
245
+ if (!validEids) {
246
+ state.truncated = true;
247
+ invalidSecurityCount += 1;
248
+ continue;
249
+ }
250
+ const originalCount = eids.length;
251
+ totalEidCount += originalCount;
252
+ const securityNameBytes = UTF8_ENCODER.encode(security).byteLength;
253
+ const canRetainSecurity = retainedSecurityCount < MAX_EID_SECURITIES && retainedSecurityNameBytes + securityNameBytes <= MAX_EID_SECURITY_NAME_BYTES;
254
+ if (!canRetainSecurity) {
255
+ state.truncated = true;
256
+ continue;
257
+ }
258
+ retainedSecurityCount += 1;
259
+ retainedSecurityNameBytes += securityNameBytes;
260
+ const remainingEidCapacity = Math.max(0, MAX_ENTITLEMENT_EIDS - retainedEidCount);
261
+ const retained = eids.slice(0, remainingEidCapacity);
262
+ retainedEidCount += retained.length;
263
+ data[security] = limitValue(retained, MAX_ENTITLEMENT_EIDS, maxStringChars, state, depth, seen);
264
+ securityCounts.push({
265
+ originalCount,
266
+ retainedCount: retained.length
267
+ });
268
+ if (retained.length !== originalCount) {
269
+ state.truncated = true;
270
+ }
271
+ }
272
+ const omittedSecurityCount = entries.length - retainedSecurityCount - invalidSecurityCount;
273
+ const wasTruncated = retainedSecurityCount !== entries.length || retainedEidCount !== totalEidCount || invalidSecurityCount > 0;
274
+ return {
275
+ data,
276
+ ...wasTruncated ? {
277
+ truncation: {
278
+ invalidSecurityCount,
279
+ omittedSecurityCount,
280
+ retainedEidCount,
281
+ retainedSecurityCount,
282
+ securityCounts,
283
+ totalEidCount,
284
+ totalSecurityCount: entries.length
285
+ }
286
+ } : {}
287
+ };
288
+ }
192
289
  function limitValue(value, maxRows, maxStringChars, state, depth = 0, seen = /* @__PURE__ */ new WeakSet()) {
193
290
  if (typeof value === "string") {
194
291
  return truncateString(value, maxStringChars, state);
@@ -210,7 +307,26 @@ function limitValue(value, maxRows, maxStringChars, state, depth = 0, seen = /*
210
307
  if (capped.length !== value.length) {
211
308
  state.truncated = true;
212
309
  }
213
- return capped.map((item) => limitValue(item, maxRows, maxStringChars, state, depth + 1, seen));
310
+ const rows = capped.map(
311
+ (item) => limitValue(item, maxRows, maxStringChars, state, depth + 1, seen)
312
+ );
313
+ const metadata = arrayMetadata(value);
314
+ if (Object.keys(metadata).length === 0) {
315
+ return rows;
316
+ }
317
+ const output = { rows };
318
+ for (const [key, entry] of Object.entries(metadata)) {
319
+ if (key === "eidData") {
320
+ const limited = limitEidData(entry, maxStringChars, state, depth + 1, seen);
321
+ output.eidData = limited.data;
322
+ if (limited.truncation !== void 0) {
323
+ output.eidDataTruncation = limited.truncation;
324
+ }
325
+ continue;
326
+ }
327
+ output[key] = limitValue(entry, maxRows, maxStringChars, state, depth + 1, seen);
328
+ }
329
+ return output;
214
330
  }
215
331
  if (typeof value === "object" && value !== null) {
216
332
  if (seen.has(value)) {
@@ -841,6 +957,7 @@ var REQUIRED_TOOL_INSTRUCTIONS = [
841
957
  "- xbbg_bds: Bloomberg bulk/table fields. Provide exactly one bulk field; do not use bds for ordinary multi-field reference data.",
842
958
  "- xbbg_bdib: intraday bars only. Provide one ticker, explicit ISO start/end datetimes with time components, a positive interval in minutes, and timezone context when datetimes are naive.",
843
959
  "- xbbg_bdtick: intraday tick data. Provide one ticker, explicit ISO start/end datetimes with time components, and explicit eventTypes unless the default event stream is intended. Use includeBrokerCodes or includeConditionCodes only when those columns are needed.",
960
+ "- xbbg_check_entitlements: checks whether the current Bloomberg identity is entitled to a nonempty list of EIDs returned by an EID-capable request. Usually use the default //blp/refdata service.",
844
961
  "- xbbg_bql: BQL expressions only when the user asks for BQL or the request is naturally expressed as a bounded BQL query. Keep queries short, explicit, and scoped to the requested universe.",
845
962
  "- xbbg_bsrch: Bloomberg search-grid or saved-search workflows only. Do not use it for ordinary security lookup.",
846
963
  "- xbbg_bqr: Bloomberg Quote Request / dealer quotes. Prefer fixed-income identifier inputs with a dealer quote source such as /isin/<ISIN>@<QUOTE_SOURCE> <MARKET_SECTOR>, explicit start/end datetimes with time components, and explicit event types.",
@@ -912,6 +1029,7 @@ var BDH_DESCRIPTION = 'Bloomberg historical time series. Requires explicit start
912
1029
  var BDS_DESCRIPTION = 'Bloomberg bulk/table reference data. Requires exactly one bulk field, not a field list. Use /isin/<ISIN> for ISINs and /cusip/<CUSIP> for CUSIPs. Example: securities ["<INDEX_TICKER> <MARKET_SECTOR>"], field "<BULK_FIELD>".';
913
1030
  var BDIB_DESCRIPTION = 'Bloomberg intraday bars. Requires one ticker plus explicit ISO start/end datetimes with time components and a positive interval in minutes. Use /isin/<ISIN> for ISINs and /cusip/<CUSIP> for CUSIPs. Example: ticker "<TICKER> <MARKET_SECTOR>", start "<START_DATETIME>", end "<END_DATETIME>", interval <MINUTES>.';
914
1031
  var BDTICK_DESCRIPTION = 'Bloomberg intraday tick data. Requires one ticker plus explicit ISO start/end datetimes with time components. Set eventTypes explicitly, for example ["<EVENT_TYPE>"], and includeBrokerCodes/includeConditionCodes only when needed.';
1032
+ var CHECK_ENTITLEMENTS_DESCRIPTION = "Check the current Bloomberg identity against entitlement IDs returned by a request with returnEids enabled. Accepts a nonempty integer EID list and defaults the service to //blp/refdata. This tool is read-only.";
915
1033
  var BQL_DESCRIPTION = "Bloomberg Query Language expression sent as one complete query string. Use for bounded universe analytics with placeholder-shaped syntax such as get(<FIELD>) for('<TICKER> <MARKET_SECTOR>'), holdings('<ETF_TICKER> <MARKET_SECTOR>'), members('<INDEX_TICKER> <MARKET_SECTOR>'), filters with with(...), or dates=range(...). Prefer xbbg_bdp/xbbg_bdh for simple reference or historical requests.";
916
1034
  var BSRCH_DESCRIPTION = 'Bloomberg search/grid request. Use for saved-search or ExcelGetGrid-style Bloomberg searches, not ordinary security lookup. Example searchSpec "<SEARCH_SPEC>".';
917
1035
  var BQR_DESCRIPTION = 'Bloomberg Quote Request / dealer quotes. Use for fixed-income dealer quote ticks, preferably with an ISIN plus dealer source such as "/isin/<ISIN>@<QUOTE_SOURCE> <MARKET_SECTOR>"; requires explicit ISO start/end datetimes with time components. Set eventTypes explicitly, for example ["<EVENT_TYPE>"].';
@@ -1948,6 +2066,7 @@ function createBdpSchema(options) {
1948
2066
  overrides: overridesMap(tool2, "overrides").describe(
1949
2067
  "Bloomberg field overrides. Use primitive values for global overrides and nested primitive maps keyed by exact security for per-security overrides."
1950
2068
  ),
2069
+ returnEids: z__namespace.boolean().optional().describe("Request Bloomberg entitlement IDs and retain them in result metadata."),
1951
2070
  securities: stringArray2(
1952
2071
  tool2,
1953
2072
  "securities",
@@ -1990,6 +2109,7 @@ function createBdhSchema(options) {
1990
2109
  "Securities exactly as the user supplied them: '<TICKER> <MARKET_SECTOR>' for Bloomberg tickers, '/isin/<ISIN>' for raw ISINs, '/cusip/<CUSIP>' for raw CUSIPs. Never invent, guess, or convert identifiers into tickers."
1991
2110
  ),
1992
2111
  start: dateField(tool2, "start").describe("Required start date. Use YYYY-MM-DD or YYYYMMDD."),
2112
+ returnEids: z__namespace.boolean().optional().describe("Request Bloomberg entitlement IDs and retain them in result metadata."),
1993
2113
  validateFields: z__namespace.boolean().optional().describe("Override field validation for this request.")
1994
2114
  }).superRefine((value, ctx) => {
1995
2115
  if (value.start > value.end) {
@@ -2013,6 +2133,7 @@ function createBdsSchema(options) {
2013
2133
  overrides: overridesMap(tool2, "overrides").describe(
2014
2134
  "Bloomberg overrides. Use primitive values for global overrides and nested primitive maps keyed by exact security for per-security overrides."
2015
2135
  ),
2136
+ returnEids: z__namespace.boolean().optional().describe("Request Bloomberg entitlement IDs and retain them in result metadata."),
2016
2137
  securities: stringArray2(
2017
2138
  tool2,
2018
2139
  "securities",
@@ -2038,6 +2159,7 @@ function createBdibSchema(options) {
2038
2159
  ),
2039
2160
  outputTz: nonEmptyString2(tool2, "outputTz", options.maxStringChars, "<TIMEZONE>").optional().describe("Optional output timezone."),
2040
2161
  requestTz: nonEmptyString2(tool2, "requestTz", options.maxStringChars, "<TIMEZONE>").optional().describe("Timezone for naive start/end datetimes."),
2162
+ returnEids: z__namespace.boolean().optional().describe("Request Bloomberg entitlement IDs and retain them in result metadata."),
2041
2163
  start: dateTimeField(tool2, "start").describe(
2042
2164
  "Required intraday start datetime. Use ISO 8601 with timezone when possible."
2043
2165
  ),
@@ -2077,6 +2199,7 @@ function createBdtickSchema(options) {
2077
2199
  ),
2078
2200
  outputTz: nonEmptyString2(tool2, "outputTz", options.maxStringChars, "<TIMEZONE>").optional().describe("Optional output timezone."),
2079
2201
  requestTz: nonEmptyString2(tool2, "requestTz", options.maxStringChars, "<TIMEZONE>").optional().describe("Timezone for naive start/end datetimes."),
2202
+ returnEids: z__namespace.boolean().optional().describe("Request Bloomberg entitlement IDs and retain them in result metadata."),
2080
2203
  start: dateTimeField(tool2, "start").describe(
2081
2204
  "Required intraday tick start datetime. Use ISO 8601 with timezone when possible."
2082
2205
  ),
@@ -2090,6 +2213,18 @@ function createBdtickSchema(options) {
2090
2213
  )
2091
2214
  });
2092
2215
  }
2216
+ function createCheckEntitlementsSchema(options) {
2217
+ const tool2 = "xbbg_check_entitlements";
2218
+ return z__namespace.object({
2219
+ eids: z__namespace.array(
2220
+ z__namespace.number().int(`${tool2}: eids must contain integers only.`).positive(`${tool2}: eids must contain positive integers only.`).max(MAX_BLOOMBERG_EID, `${tool2}: eids must be signed 32-bit integers.`)
2221
+ ).nonempty(`${tool2}: eids must contain at least one entitlement ID.`).max(
2222
+ MAX_ENTITLEMENT_EIDS,
2223
+ `${tool2}: eids must contain at most ${String(MAX_ENTITLEMENT_EIDS)} values.`
2224
+ ).describe("Nonempty list of positive signed 32-bit Bloomberg entitlement IDs."),
2225
+ service: nonEmptyString2(tool2, "service", options.maxStringChars, "//blp/refdata").optional().default("//blp/refdata").describe("Bloomberg service to check. Defaults to //blp/refdata.")
2226
+ });
2227
+ }
2093
2228
  function createBqlSchema(options) {
2094
2229
  const tool2 = "xbbg_bql";
2095
2230
  return z__namespace.object({
@@ -2557,7 +2692,8 @@ function bdpWithResolver(resolver) {
2557
2692
  includeSecurityErrors: input.includeSecurityErrors,
2558
2693
  kwargs: input.kwargs,
2559
2694
  overrides: input.overrides,
2560
- validateFields: validationSetting(resolver, input.validateFields)
2695
+ validateFields: validationSetting(resolver, input.validateFields),
2696
+ returnEids: input.returnEids
2561
2697
  };
2562
2698
  const result = await engine.bdp(input.securities, input.fields, options);
2563
2699
  return resultString2(resolver, name, result);
@@ -2586,6 +2722,7 @@ function bdhWithResolver(resolver) {
2586
2722
  kwargs: input.kwargs,
2587
2723
  overrides: input.overrides,
2588
2724
  start: input.start,
2725
+ returnEids: input.returnEids,
2589
2726
  validateFields: validationSetting(resolver, input.validateFields)
2590
2727
  };
2591
2728
  const result = await engine.bdh(input.securities, input.fields, options);
@@ -2612,6 +2749,7 @@ function bdsWithResolver(resolver) {
2612
2749
  backend: "json",
2613
2750
  kwargs: input.kwargs,
2614
2751
  overrides: input.overrides,
2752
+ returnEids: input.returnEids,
2615
2753
  validateFields: validationSetting(resolver, input.validateFields)
2616
2754
  };
2617
2755
  const result = await engine.bds(input.securities, [input.field], options);
@@ -2642,6 +2780,7 @@ function bdibWithResolver(resolver) {
2642
2780
  kwargs: input.kwargs,
2643
2781
  outputTz: input.outputTz,
2644
2782
  requestTz: input.requestTz,
2783
+ returnEids: input.returnEids,
2645
2784
  start: input.start
2646
2785
  });
2647
2786
  return resultString2(resolver, name, result);
@@ -2677,6 +2816,7 @@ function bdtickWithResolver(resolver) {
2677
2816
  kwargs: input.kwargs,
2678
2817
  outputTz: input.outputTz,
2679
2818
  requestTz: input.requestTz,
2819
+ returnEids: input.returnEids,
2680
2820
  start: input.start
2681
2821
  });
2682
2822
  return resultString2(resolver, name, result);
@@ -2692,6 +2832,31 @@ function bdtickWithResolver(resolver) {
2692
2832
  }
2693
2833
  );
2694
2834
  }
2835
+ function checkEntitlementsWithResolver(resolver) {
2836
+ const name = "xbbg_check_entitlements";
2837
+ return createBloombergStructuredTool(
2838
+ async (input) => {
2839
+ try {
2840
+ const engine = await resolver.getEngine();
2841
+ const result = await engine.checkEntitlements(input.service ?? "//blp/refdata", input.eids);
2842
+ return createToolResult(
2843
+ name,
2844
+ result,
2845
+ MAX_ENTITLEMENT_EIDS,
2846
+ resolver.options.maxStringChars
2847
+ );
2848
+ } catch (error) {
2849
+ throwWithToolContext(name, error);
2850
+ }
2851
+ },
2852
+ {
2853
+ description: CHECK_ENTITLEMENTS_DESCRIPTION,
2854
+ name,
2855
+ responseFormat: "content_and_artifact",
2856
+ schema: createCheckEntitlementsSchema(resolver.options)
2857
+ }
2858
+ );
2859
+ }
2695
2860
  function bqlWithResolver(resolver) {
2696
2861
  const name = "xbbg_bql";
2697
2862
  return createBloombergStructuredTool(
@@ -3064,6 +3229,9 @@ function createBdibTool(options = {}) {
3064
3229
  function createBdtickTool(options = {}) {
3065
3230
  return bdtickWithResolver(createCoreResolver(options));
3066
3231
  }
3232
+ function createCheckEntitlementsTool(options = {}) {
3233
+ return checkEntitlementsWithResolver(createCoreResolver(options));
3234
+ }
3067
3235
  function createBqlTool(options = {}) {
3068
3236
  return bqlWithResolver(createCoreResolver(options));
3069
3237
  }
@@ -3115,6 +3283,7 @@ var CORE_TOOL_DEFINITIONS = Object.freeze([
3115
3283
  { create: bdsWithResolver, name: "xbbg_bds" },
3116
3284
  { create: bdibWithResolver, name: "xbbg_bdib" },
3117
3285
  { create: bdtickWithResolver, name: "xbbg_bdtick" },
3286
+ { create: checkEntitlementsWithResolver, name: "xbbg_check_entitlements" },
3118
3287
  { create: bqlWithResolver, name: "xbbg_bql" },
3119
3288
  { create: bsrchWithResolver, name: "xbbg_bsrch" },
3120
3289
  { create: bqrWithResolver, name: "xbbg_bqr" },
@@ -3166,6 +3335,7 @@ exports.createBloombergTools = createBloombergTools;
3166
3335
  exports.createBqlTool = createBqlTool;
3167
3336
  exports.createBqrTool = createBqrTool;
3168
3337
  exports.createBsrchTool = createBsrchTool;
3338
+ exports.createCheckEntitlementsTool = createCheckEntitlementsTool;
3169
3339
  exports.createCorporateBondsTool = createCorporateBondsTool;
3170
3340
  exports.createDepthSnapshotTool = createDepthSnapshotTool;
3171
3341
  exports.createEtfHoldingsTool = createEtfHoldingsTool;