@xbbg/langgraph 1.3.1 → 1.4.2

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/index.js CHANGED
@@ -888,7 +888,7 @@ var OPTIONAL_LIMIT_INSTRUCTIONS = [
888
888
  "## Request limits and inputs",
889
889
  "- Keep Bloomberg requests bounded: explicit securities, explicit fields, explicit dates, limited rows, and no broad exploratory pulls unless the user narrows the universe.",
890
890
  "- Respect configured tool limits for securities, fields, rows, string size, BQL length, and search spec length. Ask the user to narrow the request rather than exceeding them.",
891
- "- Use flat primitive overrides and kwargs only: string, number, or boolean values. Do not send nested objects, arrays, or inferred defaults as overrides."
891
+ "- Use primitive kwargs only: string, number, or boolean values. For overrides on xbbg_bdp/xbbg_bdh/xbbg_bds, use primitive values for global overrides and nested primitive maps keyed by exact security for per-security overrides. Do not send other nested objects, arrays, or inferred defaults."
892
892
  ];
893
893
  var BLOOMBERG_TOOL_INSTRUCTIONS = [
894
894
  ...REQUIRED_TOOL_INSTRUCTIONS,
@@ -1176,10 +1176,19 @@ function columnsSchema(options) {
1176
1176
  }
1177
1177
  function calculateSchema(options) {
1178
1178
  return z__namespace.object({
1179
- levels: z__namespace.array(z__namespace.number().nullable()).min(1).max(options.maxFields).describe("Reference level values."),
1179
+ levels: z__namespace.array(z__namespace.number().nullable()).min(1).max(options.maxFields).describe("Hierarchy level values; supported levels are 1, 2, or null."),
1180
1180
  operation: z__namespace.literal("calculate_level_percentages").describe("Numeric helper operation to run."),
1181
1181
  values: z__namespace.array(z__namespace.number().nullable()).min(1).max(options.maxFields).describe("Observed values.")
1182
1182
  }).strict().superRefine((input, ctx) => {
1183
+ input.levels.forEach((level, index) => {
1184
+ if (level !== null && level !== 1 && level !== 2) {
1185
+ ctx.addIssue({
1186
+ code: z__namespace.ZodIssueCode.custom,
1187
+ message: "levels must contain only 1, 2, or null",
1188
+ path: ["levels", index]
1189
+ });
1190
+ }
1191
+ });
1183
1192
  if (input.values.length !== input.levels.length) {
1184
1193
  ctx.addIssue({
1185
1194
  code: z__namespace.ZodIssueCode.custom,
@@ -1820,6 +1829,60 @@ function primitiveMap(tool2, field) {
1820
1829
  return normalized;
1821
1830
  });
1822
1831
  }
1832
+ function overridesMap(tool2, field) {
1833
+ return z__namespace.record(
1834
+ z__namespace.string().min(1),
1835
+ z__namespace.union([primitiveSchema, z__namespace.record(z__namespace.string().min(1), primitiveSchema)])
1836
+ ).optional().transform((value, context) => {
1837
+ if (value === void 0) {
1838
+ return void 0;
1839
+ }
1840
+ const normalized = {};
1841
+ for (const [key, entry] of Object.entries(value)) {
1842
+ const normalizedKey = key.trim();
1843
+ if (normalizedKey.length === 0) {
1844
+ return normalizationIssue(context, tool2, field, new TypeError("contains an empty key"));
1845
+ }
1846
+ if (typeof entry !== "object") {
1847
+ if (typeof entry === "string" && entry.length === 0) {
1848
+ return normalizationIssue(
1849
+ context,
1850
+ tool2,
1851
+ field,
1852
+ new TypeError(`${normalizedKey} must not be an empty string`)
1853
+ );
1854
+ }
1855
+ normalized[normalizedKey] = entry;
1856
+ continue;
1857
+ }
1858
+ const normalizedOverrides = {};
1859
+ for (const [overrideKey, overrideValue] of Object.entries(entry)) {
1860
+ const normalizedOverrideKey = overrideKey.trim();
1861
+ if (normalizedOverrideKey.length === 0) {
1862
+ return normalizationIssue(
1863
+ context,
1864
+ tool2,
1865
+ field,
1866
+ new TypeError(`${normalizedKey} contains an empty override key`)
1867
+ );
1868
+ }
1869
+ if (typeof overrideValue === "string" && overrideValue.length === 0) {
1870
+ return normalizationIssue(
1871
+ context,
1872
+ tool2,
1873
+ field,
1874
+ new TypeError(
1875
+ `${normalizedKey}.${normalizedOverrideKey} must not be an empty string`
1876
+ )
1877
+ );
1878
+ }
1879
+ normalizedOverrides[normalizedOverrideKey] = overrideValue;
1880
+ }
1881
+ normalized[normalizedKey] = normalizedOverrides;
1882
+ }
1883
+ return normalized;
1884
+ });
1885
+ }
1823
1886
  function dateField(tool2, field) {
1824
1887
  return z__namespace.union([z__namespace.string(), z__namespace.number()]).transform((value, context) => {
1825
1888
  try {
@@ -1882,8 +1945,8 @@ function createBdpSchema(options) {
1882
1945
  kwargs: primitiveMap(tool2, "kwargs").describe(
1883
1946
  "Advanced Bloomberg request kwargs as flat string/number/boolean values only."
1884
1947
  ),
1885
- overrides: primitiveMap(tool2, "overrides").describe(
1886
- "Bloomberg field overrides as flat string/number/boolean values only."
1948
+ overrides: overridesMap(tool2, "overrides").describe(
1949
+ "Bloomberg field overrides. Use primitive values for global overrides and nested primitive maps keyed by exact security for per-security overrides."
1887
1950
  ),
1888
1951
  securities: stringArray2(
1889
1952
  tool2,
@@ -1914,8 +1977,8 @@ function createBdhSchema(options) {
1914
1977
  kwargs: primitiveMap(tool2, "kwargs").describe(
1915
1978
  "Advanced Bloomberg request kwargs as flat string/number/boolean values only."
1916
1979
  ),
1917
- overrides: primitiveMap(tool2, "overrides").describe(
1918
- "Bloomberg overrides as flat string/number/boolean values only."
1980
+ overrides: overridesMap(tool2, "overrides").describe(
1981
+ "Bloomberg overrides. Use primitive values for global overrides and nested primitive maps keyed by exact security for per-security overrides."
1919
1982
  ),
1920
1983
  securities: stringArray2(
1921
1984
  tool2,
@@ -1947,8 +2010,8 @@ function createBdsSchema(options) {
1947
2010
  kwargs: primitiveMap(tool2, "kwargs").describe(
1948
2011
  "Advanced Bloomberg request kwargs as flat string/number/boolean values only."
1949
2012
  ),
1950
- overrides: primitiveMap(tool2, "overrides").describe(
1951
- "Bloomberg overrides as flat string/number/boolean values only."
2013
+ overrides: overridesMap(tool2, "overrides").describe(
2014
+ "Bloomberg overrides. Use primitive values for global overrides and nested primitive maps keyed by exact security for per-security overrides."
1952
2015
  ),
1953
2016
  securities: stringArray2(
1954
2017
  tool2,
@@ -2488,14 +2551,15 @@ function bdpWithResolver(resolver) {
2488
2551
  async (input) => {
2489
2552
  try {
2490
2553
  const engine = await resolver.getEngine();
2491
- const result = await engine.bdp(input.securities, input.fields, {
2554
+ const options = {
2492
2555
  backend: "json",
2493
2556
  format: input.format,
2494
2557
  includeSecurityErrors: input.includeSecurityErrors,
2495
2558
  kwargs: input.kwargs,
2496
2559
  overrides: input.overrides,
2497
2560
  validateFields: validationSetting(resolver, input.validateFields)
2498
- });
2561
+ };
2562
+ const result = await engine.bdp(input.securities, input.fields, options);
2499
2563
  return resultString2(resolver, name, result);
2500
2564
  } catch (error) {
2501
2565
  throwWithToolContext(name, error);
@@ -2515,7 +2579,7 @@ function bdhWithResolver(resolver) {
2515
2579
  async (input) => {
2516
2580
  try {
2517
2581
  const engine = await resolver.getEngine();
2518
- const result = await engine.bdh(input.securities, input.fields, {
2582
+ const options = {
2519
2583
  backend: "json",
2520
2584
  end: input.end,
2521
2585
  format: input.format,
@@ -2523,7 +2587,8 @@ function bdhWithResolver(resolver) {
2523
2587
  overrides: input.overrides,
2524
2588
  start: input.start,
2525
2589
  validateFields: validationSetting(resolver, input.validateFields)
2526
- });
2590
+ };
2591
+ const result = await engine.bdh(input.securities, input.fields, options);
2527
2592
  return resultString2(resolver, name, result);
2528
2593
  } catch (error) {
2529
2594
  throwWithToolContext(name, error);
@@ -2543,12 +2608,13 @@ function bdsWithResolver(resolver) {
2543
2608
  async (input) => {
2544
2609
  try {
2545
2610
  const engine = await resolver.getEngine();
2546
- const result = await engine.bds(input.securities, [input.field], {
2611
+ const options = {
2547
2612
  backend: "json",
2548
2613
  kwargs: input.kwargs,
2549
2614
  overrides: input.overrides,
2550
2615
  validateFields: validationSetting(resolver, input.validateFields)
2551
- });
2616
+ };
2617
+ const result = await engine.bds(input.securities, [input.field], options);
2552
2618
  return resultString2(resolver, name, result);
2553
2619
  } catch (error) {
2554
2620
  throwWithToolContext(name, error);