@xbbg/langgraph 1.3.0 → 1.4.1
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 +29 -0
- package/dist/index.d.ts +66 -3
- package/dist/index.js +512 -17
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -166,6 +166,7 @@ Extension helper tools:
|
|
|
166
166
|
- `xbbg_ext_constants` - static constants and formatting helpers for dates, futures months, dividend types, and ETF/dividend columns.
|
|
167
167
|
- `xbbg_ext_columns` - rename helpers for dividend, ETF, and earnings-shaped Bloomberg responses.
|
|
168
168
|
- `xbbg_ext_calculate` - small numeric helper for level percentage calculations.
|
|
169
|
+
- `xbbg_ext_chart_spec` - renderer-neutral chart specs for frontend generative UI; converts bounded rows from `xbbg_bdh`, `xbbg_bdib`, holdings, depth, or already-shaped row data into Vega-Lite JSON.
|
|
169
170
|
|
|
170
171
|
```ts
|
|
171
172
|
import { createBloombergExtTools, createAllBloombergTools } from "@xbbg/langgraph";
|
|
@@ -176,6 +177,34 @@ const allTools = createAllBloombergTools({
|
|
|
176
177
|
});
|
|
177
178
|
```
|
|
178
179
|
|
|
180
|
+
### Chart specs and generative UI frontends
|
|
181
|
+
|
|
182
|
+
`xbbg_ext_chart_spec` does not fetch Bloomberg data and does not render images. Use a data tool first, then pass its bounded rows into the chart-spec helper. The result is a portable visualization payload:
|
|
183
|
+
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"kind": "xbbg.visualization",
|
|
187
|
+
"component": "xbbg_chart",
|
|
188
|
+
"renderer": "vega-lite",
|
|
189
|
+
"spec": { "data": { "values": [] }, "mark": { "type": "line" } }
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Frontend runtimes should register their own `xbbg_chart` component and render `data.spec` with their preferred Vega-Lite React wrapper. This keeps `@xbbg/langgraph` dependency-free and works with CopilotKit `useRenderTool`, assistant-ui data/generative UI renderers, Vercel AI SDK tool parts, or LangGraph `typedUi()` adapters.
|
|
194
|
+
|
|
195
|
+
Example tool input after a historical request:
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"source": "bdh",
|
|
200
|
+
"rows": [{ "ticker": "AAPL US Equity", "date": "20240102", "value": 190.1 }],
|
|
201
|
+
"xField": "date",
|
|
202
|
+
"yFields": ["value"],
|
|
203
|
+
"seriesField": "ticker",
|
|
204
|
+
"title": "AAPL PX_LAST"
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
179
208
|
## Engine handling
|
|
180
209
|
|
|
181
210
|
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.
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ type XbbgCoreModule = typeof xbbg;
|
|
|
5
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
6
|
type XbbgCoreLike = Pick<XbbgCoreModule, "connect" | "ext">;
|
|
7
7
|
|
|
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_market_session", "xbbg_ext_yas_overrides", "xbbg_ext_constants", "xbbg_ext_columns", "xbbg_ext_calculate"];
|
|
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"];
|
|
9
9
|
type BloombergToolName = (typeof BLOOMBERG_TOOL_NAMES)[number];
|
|
10
10
|
interface BloombergToolsOptions {
|
|
11
11
|
readonly engine?: XbbgEngineLike;
|
|
@@ -75,7 +75,7 @@ interface BloombergToolInstructionsOptions {
|
|
|
75
75
|
}
|
|
76
76
|
declare function getBloombergToolInstructions(options?: BloombergToolInstructionsOptions): string;
|
|
77
77
|
|
|
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_market_session" | "xbbg_ext_yas_overrides" | "xbbg_ext_constants" | "xbbg_ext_columns" | "xbbg_ext_calculate")[];
|
|
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")[];
|
|
79
79
|
declare function createExtTickerTool(options?: BloombergToolsOptions): BloombergTool;
|
|
80
80
|
declare function createExtFuturesTool(options?: BloombergToolsOptions): BloombergTool;
|
|
81
81
|
declare function createExtCdxTool(options?: BloombergToolsOptions): BloombergTool;
|
|
@@ -86,6 +86,7 @@ declare function createExtYasOverridesTool(options?: BloombergToolsOptions): Blo
|
|
|
86
86
|
declare function createExtConstantsTool(options?: BloombergToolsOptions): BloombergTool;
|
|
87
87
|
declare function createExtColumnsTool(options?: BloombergToolsOptions): BloombergTool;
|
|
88
88
|
declare function createExtCalculateTool(options?: BloombergToolsOptions): BloombergTool;
|
|
89
|
+
declare function createExtChartSpecTool(options?: BloombergToolsOptions): BloombergTool;
|
|
89
90
|
declare function createBloombergExtTools(options?: BloombergToolsOptions): BloombergTool[];
|
|
90
91
|
|
|
91
92
|
interface ToolEnvelope {
|
|
@@ -111,6 +112,68 @@ interface ToolInvocationConfig {
|
|
|
111
112
|
*/
|
|
112
113
|
declare function toolParameterJsonSchema(toolInstance: StructuredToolInterface): Record<string, unknown>;
|
|
113
114
|
|
|
115
|
+
type BloombergChartSource = "bdh" | "bdib" | "holdings" | "depth" | "rows";
|
|
116
|
+
type ChartKind = "line" | "area" | "bar" | "scatter" | "candlestick" | "depth";
|
|
117
|
+
type ChartRenderer = "vega-lite";
|
|
118
|
+
type ChartScalar = string | number | boolean | null;
|
|
119
|
+
type ChartRow = Readonly<Record<string, ChartScalar>>;
|
|
120
|
+
interface ChartSpecInput {
|
|
121
|
+
readonly source: BloombergChartSource;
|
|
122
|
+
readonly rows: readonly ChartRow[];
|
|
123
|
+
readonly renderer?: ChartRenderer;
|
|
124
|
+
readonly chart?: ChartKind;
|
|
125
|
+
readonly title?: string;
|
|
126
|
+
readonly xField?: string;
|
|
127
|
+
readonly yFields?: readonly string[];
|
|
128
|
+
readonly seriesField?: string;
|
|
129
|
+
readonly labelField?: string;
|
|
130
|
+
readonly valueField?: string;
|
|
131
|
+
readonly openField?: string;
|
|
132
|
+
readonly highField?: string;
|
|
133
|
+
readonly lowField?: string;
|
|
134
|
+
readonly closeField?: string;
|
|
135
|
+
readonly sideField?: string;
|
|
136
|
+
readonly priceField?: string;
|
|
137
|
+
readonly sizeField?: string;
|
|
138
|
+
readonly maxPoints?: number;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
interface ChartSpecSummary {
|
|
142
|
+
readonly chart: ChartKind;
|
|
143
|
+
readonly inputRows: number;
|
|
144
|
+
readonly renderer: "vega-lite";
|
|
145
|
+
readonly rowCount: number;
|
|
146
|
+
readonly source: BloombergChartSource;
|
|
147
|
+
readonly title: string;
|
|
148
|
+
readonly truncatedInput: boolean;
|
|
149
|
+
readonly xField?: string;
|
|
150
|
+
readonly yFields: readonly string[];
|
|
151
|
+
readonly seriesField?: string;
|
|
152
|
+
}
|
|
153
|
+
interface VegaLiteSpec {
|
|
154
|
+
readonly $schema: "https://vega.github.io/schema/vega-lite/v5.json";
|
|
155
|
+
readonly data: {
|
|
156
|
+
readonly values: readonly ChartRow[];
|
|
157
|
+
};
|
|
158
|
+
readonly description: string;
|
|
159
|
+
readonly title: string;
|
|
160
|
+
readonly [key: string]: unknown;
|
|
161
|
+
}
|
|
162
|
+
interface ChartSpecOutput {
|
|
163
|
+
readonly kind: "xbbg.visualization";
|
|
164
|
+
readonly version: 1;
|
|
165
|
+
readonly component: "xbbg_chart";
|
|
166
|
+
readonly renderer: "vega-lite";
|
|
167
|
+
readonly rowCount: number;
|
|
168
|
+
readonly inputRowCount: number;
|
|
169
|
+
readonly truncatedInput: boolean;
|
|
170
|
+
readonly source: BloombergChartSource;
|
|
171
|
+
readonly chart: ChartKind;
|
|
172
|
+
readonly summary: ChartSpecSummary;
|
|
173
|
+
readonly spec: VegaLiteSpec;
|
|
174
|
+
readonly warnings: readonly string[];
|
|
175
|
+
}
|
|
176
|
+
|
|
114
177
|
declare function createAllBloombergTools(options?: BloombergToolsOptions): BloombergTool[];
|
|
115
178
|
|
|
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 };
|
|
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 };
|