@blaxel/langgraph 0.2.49-dev.214 → 0.2.49-dev1

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.
Files changed (34) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/types/tools.d.ts +6 -2
  3. package/dist/esm/.tsbuildinfo +1 -1
  4. package/dist/index.d.ts +3 -0
  5. package/dist/index.js +19 -0
  6. package/dist/model/cohere.d.ts +6 -0
  7. package/dist/model/cohere.js +172 -0
  8. package/dist/model/google-genai/chat_models.d.ts +557 -0
  9. package/dist/model/google-genai/chat_models.js +755 -0
  10. package/dist/model/google-genai/embeddings.d.ts +94 -0
  11. package/dist/model/google-genai/embeddings.js +111 -0
  12. package/dist/model/google-genai/index.d.ts +2 -0
  13. package/dist/model/google-genai/index.js +18 -0
  14. package/dist/model/google-genai/output_parsers.d.ts +20 -0
  15. package/dist/model/google-genai/output_parsers.js +50 -0
  16. package/dist/model/google-genai/types.d.ts +3 -0
  17. package/dist/model/google-genai/types.js +2 -0
  18. package/dist/model/google-genai/utils/common.d.ts +22 -0
  19. package/dist/model/google-genai/utils/common.js +386 -0
  20. package/dist/model/google-genai/utils/tools.d.ts +10 -0
  21. package/dist/model/google-genai/utils/tools.js +110 -0
  22. package/dist/model/google-genai/utils/zod_to_genai_parameters.d.ts +13 -0
  23. package/dist/model/google-genai/utils/zod_to_genai_parameters.js +46 -0
  24. package/dist/model/google-genai.d.ts +11 -0
  25. package/dist/model/google-genai.js +30 -0
  26. package/dist/model/xai.d.ts +41 -0
  27. package/dist/model/xai.js +82 -0
  28. package/dist/model.d.ts +2 -0
  29. package/dist/model.js +141 -0
  30. package/dist/telemetry.d.ts +1 -0
  31. package/dist/telemetry.js +24 -0
  32. package/dist/tools.d.ts +15 -0
  33. package/dist/tools.js +24 -0
  34. package/package.json +2 -2
@@ -0,0 +1,3 @@
1
+ export * from "./model.js";
2
+ export * from "./tools.js";
3
+ import "./telemetry.js";
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./model.js"), exports);
18
+ __exportStar(require("./tools.js"), exports);
19
+ require("./telemetry.js");
@@ -0,0 +1,6 @@
1
+ import { FetchFunction } from "cohere-ai/core";
2
+ /**
3
+ * Creates a custom fetcher for CohereClient that adds dynamic headers
4
+ * CohereClient's fetcher expects a function that intercepts fetch requests
5
+ */
6
+ export declare const createCohereFetcher: () => FetchFunction;
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCohereFetcher = void 0;
4
+ const core_1 = require("@blaxel/core");
5
+ /**
6
+ * Creates a custom fetcher for CohereClient that adds dynamic headers
7
+ * CohereClient's fetcher expects a function that intercepts fetch requests
8
+ */
9
+ const createCohereFetcher = () => {
10
+ // Return a function that matches CohereClient's FetchFunction interface
11
+ const fetcher = async (args) => {
12
+ await (0, core_1.authenticate)();
13
+ const dynamicHeaders = core_1.settings.headers;
14
+ // Extract all fields from args
15
+ const { url, method, headers: argsHeaders, body, contentType, queryParameters, timeoutMs, withCredentials, abortSignal, requestType, responseType, duplex } = args;
16
+ // Build URL with query parameters
17
+ let requestUrl = url;
18
+ if (queryParameters) {
19
+ const params = new URLSearchParams();
20
+ Object.entries(queryParameters).forEach(([key, value]) => {
21
+ if (Array.isArray(value)) {
22
+ value.forEach(v => {
23
+ if (typeof v === 'object' && v !== null) {
24
+ params.append(key, JSON.stringify(v));
25
+ }
26
+ else {
27
+ params.append(key, String(v));
28
+ }
29
+ });
30
+ }
31
+ else if (typeof value === 'object' && value !== null) {
32
+ params.append(key, JSON.stringify(value));
33
+ }
34
+ else {
35
+ params.append(key, String(value));
36
+ }
37
+ });
38
+ const queryString = params.toString();
39
+ if (queryString) {
40
+ requestUrl += (url.includes('?') ? '&' : '?') + queryString;
41
+ }
42
+ }
43
+ // Merge headers and filter out undefined values
44
+ const mergedHeaders = {
45
+ ...(argsHeaders || {}),
46
+ ...dynamicHeaders,
47
+ };
48
+ // Add content-type if specified
49
+ if (contentType) {
50
+ mergedHeaders['Content-Type'] = contentType;
51
+ }
52
+ // Filter out undefined values
53
+ const headers = Object.entries(mergedHeaders).reduce((acc, [key, value]) => {
54
+ if (value !== undefined) {
55
+ acc[key] = value;
56
+ }
57
+ return acc;
58
+ }, {});
59
+ // Prepare body based on requestType
60
+ let requestBody;
61
+ if (body !== undefined) {
62
+ if (requestType === 'json' || !requestType) {
63
+ requestBody = JSON.stringify(body);
64
+ }
65
+ else if (requestType === 'bytes' && body instanceof Uint8Array) {
66
+ // Create a new ArrayBuffer from the Uint8Array to avoid SharedArrayBuffer issues
67
+ const arrayBuffer = new ArrayBuffer(body.length);
68
+ const view = new Uint8Array(arrayBuffer);
69
+ view.set(body);
70
+ requestBody = arrayBuffer;
71
+ }
72
+ else if (requestType === 'file' && body instanceof Blob) {
73
+ requestBody = body;
74
+ }
75
+ else if (typeof body === 'string') {
76
+ requestBody = body;
77
+ }
78
+ else {
79
+ requestBody = JSON.stringify(body);
80
+ }
81
+ }
82
+ try {
83
+ // Create abort controller for timeout
84
+ const controller = new AbortController();
85
+ let timeoutId;
86
+ if (timeoutMs) {
87
+ timeoutId = setTimeout(() => controller.abort(), timeoutMs);
88
+ }
89
+ // Merge abort signals
90
+ const signal = abortSignal
91
+ ? AbortSignal.any([abortSignal, controller.signal])
92
+ : controller.signal;
93
+ // Make the request with merged headers
94
+ const requestInit = {
95
+ method: method,
96
+ headers,
97
+ body: requestBody,
98
+ credentials: withCredentials ? 'include' : 'same-origin',
99
+ signal,
100
+ };
101
+ // Add duplex if specified (for streaming)
102
+ if (duplex) {
103
+ requestInit.duplex = duplex;
104
+ }
105
+ const response = await fetch(requestUrl, requestInit);
106
+ // Clear timeout
107
+ if (timeoutId) {
108
+ clearTimeout(timeoutId);
109
+ }
110
+ // Handle response based on responseType
111
+ let responseBody;
112
+ if (response.ok) {
113
+ if (responseType === 'blob') {
114
+ responseBody = await response.blob();
115
+ }
116
+ else if (responseType === 'text') {
117
+ responseBody = await response.text();
118
+ }
119
+ else if (responseType === 'arrayBuffer') {
120
+ responseBody = await response.arrayBuffer();
121
+ }
122
+ else if (responseType === 'streaming' || responseType === 'sse') {
123
+ // For streaming, return the response body stream
124
+ responseBody = response.body;
125
+ }
126
+ else {
127
+ // Default to JSON
128
+ responseBody = await response.json();
129
+ }
130
+ // Return success response in the format CohereClient expects
131
+ return {
132
+ ok: true,
133
+ body: responseBody,
134
+ headers: Object.fromEntries(response.headers.entries()),
135
+ };
136
+ }
137
+ else {
138
+ // Return error response in the format CohereClient expects
139
+ const errorBody = await response.text();
140
+ return {
141
+ ok: false,
142
+ error: {
143
+ reason: "status-code",
144
+ statusCode: response.status,
145
+ body: errorBody,
146
+ },
147
+ };
148
+ }
149
+ }
150
+ catch (error) {
151
+ // Check if it's a timeout error
152
+ if (error instanceof Error && error.name === 'AbortError') {
153
+ return {
154
+ ok: false,
155
+ error: {
156
+ reason: "timeout",
157
+ },
158
+ };
159
+ }
160
+ // Return unknown error
161
+ return {
162
+ ok: false,
163
+ error: {
164
+ reason: "unknown",
165
+ errorMessage: error instanceof Error ? error.message : String(error),
166
+ },
167
+ };
168
+ }
169
+ };
170
+ return fetcher;
171
+ };
172
+ exports.createCohereFetcher = createCohereFetcher;