@spendgraph/tools 0.3.0 → 0.3.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.
@@ -6,7 +6,7 @@ export function httpRequest(opts) {
6
6
  if (!opts.allow?.length) {
7
7
  throw new Error("httpRequest needs an allow list of hosts; there is no safe default.");
8
8
  }
9
- const doFetch = opts.fetch ?? globalThis.fetch;
9
+ const doFetch = opts.fetch ?? globalThis.fetch.bind(globalThis);
10
10
  const maxChars = opts.maxChars ?? DEFAULT_MAX_CHARS;
11
11
  return tool({
12
12
  name: "http_request",
@@ -26,7 +26,7 @@ export function webSearch(opts) {
26
26
  if (!opts.apiKey?.trim()) {
27
27
  throw new Error("webSearch needs a Perplexity apiKey; it will not read one from the process.");
28
28
  }
29
- const doFetch = opts.fetch ?? globalThis.fetch;
29
+ const doFetch = opts.fetch ?? globalThis.fetch.bind(globalThis);
30
30
  const maxDepth = opts.maxDepth ?? "pro";
31
31
  return tool({
32
32
  name: "web_search",
@@ -36,7 +36,7 @@ function deadlineSignal(timeoutMs, caller) {
36
36
  };
37
37
  }
38
38
  export function createRequest(config = {}) {
39
- const doFetch = config.fetch ?? globalThis.fetch;
39
+ const doFetch = config.fetch ?? globalThis.fetch.bind(globalThis);
40
40
  const base = (config.baseUrl ?? MOA_BASE_URL).replace(/\/+$/, "");
41
41
  return async function request(path, opts = {}) {
42
42
  const timeoutMs = opts.timeoutMs ?? config.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spendgraph/tools",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Declare a tool once, offer the right few, and record what was called.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -49,10 +49,10 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@locusgraph/client": "^0.8.1",
52
- "@spendgraph/sdk": "^0.3.0"
52
+ "@spendgraph/sdk": "^0.3.2"
53
53
  },
54
54
  "devDependencies": {
55
- "@spendgraph/prompt": "^0.3.0",
55
+ "@spendgraph/prompt": "^0.3.2",
56
56
  "typescript": "^5"
57
57
  },
58
58
  "engines": {