@blinkdotnew/sdk 2.3.2 → 2.3.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/dist/index.d.mts +88 -11
- package/dist/index.d.ts +88 -11
- package/dist/index.js +66 -19
- package/dist/index.mjs +66 -20
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1145,6 +1145,20 @@ declare class HttpClient {
|
|
|
1145
1145
|
};
|
|
1146
1146
|
};
|
|
1147
1147
|
}, signal?: AbortSignal): Promise<Response>;
|
|
1148
|
+
/**
|
|
1149
|
+
* RAG AI Search streaming request
|
|
1150
|
+
* Returns raw Response for SSE streaming
|
|
1151
|
+
*/
|
|
1152
|
+
ragAiSearchStream(body: {
|
|
1153
|
+
collection_id?: string;
|
|
1154
|
+
collection_name?: string;
|
|
1155
|
+
query: string;
|
|
1156
|
+
model?: string;
|
|
1157
|
+
max_context_chunks?: number;
|
|
1158
|
+
score_threshold?: number;
|
|
1159
|
+
system_prompt?: string;
|
|
1160
|
+
stream: true;
|
|
1161
|
+
}, signal?: AbortSignal): Promise<Response>;
|
|
1148
1162
|
/**
|
|
1149
1163
|
* Data-specific requests
|
|
1150
1164
|
*/
|
|
@@ -2085,6 +2099,8 @@ interface AISearchOptions {
|
|
|
2085
2099
|
scoreThreshold?: number;
|
|
2086
2100
|
systemPrompt?: string;
|
|
2087
2101
|
stream?: boolean;
|
|
2102
|
+
/** AbortSignal for cancellation (streaming only) */
|
|
2103
|
+
signal?: AbortSignal;
|
|
2088
2104
|
}
|
|
2089
2105
|
interface ListDocumentsOptions {
|
|
2090
2106
|
collectionId?: string;
|
|
@@ -2228,6 +2244,13 @@ interface SandboxCreateOptions {
|
|
|
2228
2244
|
timeoutMs?: number;
|
|
2229
2245
|
/** Custom metadata for tracking */
|
|
2230
2246
|
metadata?: Record<string, string>;
|
|
2247
|
+
/**
|
|
2248
|
+
* Secret names to inject as environment variables.
|
|
2249
|
+
* Secrets are resolved server-side from project secrets vault.
|
|
2250
|
+
* Add secrets via Workspace > Secrets or request_secret tool.
|
|
2251
|
+
* @example ['ANTHROPIC_API_KEY', 'GITHUB_TOKEN']
|
|
2252
|
+
*/
|
|
2253
|
+
secrets?: string[];
|
|
2231
2254
|
}
|
|
2232
2255
|
interface SandboxConnectOptions {
|
|
2233
2256
|
/** Reset inactivity timeout in ms (default: 5 min) */
|
|
@@ -2290,6 +2313,23 @@ declare class BlinkSandboxImpl implements BlinkSandbox {
|
|
|
2290
2313
|
* Factory function and client class for the Blink SDK
|
|
2291
2314
|
*/
|
|
2292
2315
|
|
|
2316
|
+
/**
|
|
2317
|
+
* Get the default Blink client instance.
|
|
2318
|
+
* Returns the client created by createClient().
|
|
2319
|
+
*
|
|
2320
|
+
* @throws Error if createClient() hasn't been called yet
|
|
2321
|
+
* @returns The default BlinkClient instance
|
|
2322
|
+
*
|
|
2323
|
+
* @example
|
|
2324
|
+
* ```ts
|
|
2325
|
+
* // First, create client somewhere in your app
|
|
2326
|
+
* createClient({ projectId: '...', secretKey: '...' })
|
|
2327
|
+
*
|
|
2328
|
+
* // Later, get the default client
|
|
2329
|
+
* const client = getDefaultClient()
|
|
2330
|
+
* ```
|
|
2331
|
+
*/
|
|
2332
|
+
declare function getDefaultClient(): BlinkClientImpl;
|
|
2293
2333
|
interface BlinkClient {
|
|
2294
2334
|
auth: BlinkAuth;
|
|
2295
2335
|
db: BlinkDatabase;
|
|
@@ -2304,8 +2344,39 @@ interface BlinkClient {
|
|
|
2304
2344
|
rag: BlinkRAG;
|
|
2305
2345
|
sandbox: BlinkSandbox;
|
|
2306
2346
|
}
|
|
2347
|
+
declare class BlinkClientImpl implements BlinkClient {
|
|
2348
|
+
auth: BlinkAuth;
|
|
2349
|
+
db: BlinkDatabase;
|
|
2350
|
+
storage: BlinkStorage;
|
|
2351
|
+
ai: BlinkAI;
|
|
2352
|
+
data: BlinkData;
|
|
2353
|
+
realtime: BlinkRealtime;
|
|
2354
|
+
notifications: BlinkNotifications;
|
|
2355
|
+
analytics: BlinkAnalytics;
|
|
2356
|
+
connectors: BlinkConnectors;
|
|
2357
|
+
functions: BlinkFunctions;
|
|
2358
|
+
rag: BlinkRAG;
|
|
2359
|
+
sandbox: BlinkSandbox;
|
|
2360
|
+
/** @internal HTTP client for Agent auto-binding */
|
|
2361
|
+
_httpClient: HttpClient;
|
|
2362
|
+
constructor(config: BlinkClientConfig);
|
|
2363
|
+
}
|
|
2307
2364
|
/**
|
|
2308
|
-
* Create a new Blink client instance
|
|
2365
|
+
* Create a new Blink client instance.
|
|
2366
|
+
* This also sets the default client for Agent auto-binding.
|
|
2367
|
+
*
|
|
2368
|
+
* @example
|
|
2369
|
+
* ```ts
|
|
2370
|
+
* // Create client (call once in your app)
|
|
2371
|
+
* const blink = createClient({
|
|
2372
|
+
* projectId: 'my-project',
|
|
2373
|
+
* secretKey: 'sk_...',
|
|
2374
|
+
* })
|
|
2375
|
+
*
|
|
2376
|
+
* // Now Agent works without explicit binding
|
|
2377
|
+
* const agent = new Agent({ model: 'openai/gpt-4o' })
|
|
2378
|
+
* await agent.generate({ prompt: 'Hello!' })
|
|
2379
|
+
* ```
|
|
2309
2380
|
*/
|
|
2310
2381
|
declare function createClient(config: BlinkClientConfig): BlinkClient;
|
|
2311
2382
|
|
|
@@ -2604,6 +2675,8 @@ interface AgentResponse {
|
|
|
2604
2675
|
* - Create agent instance with config
|
|
2605
2676
|
* - Call agent.generate() for non-streaming
|
|
2606
2677
|
* - Call agent.stream() for streaming
|
|
2678
|
+
*
|
|
2679
|
+
* Auto-binds to default client when createClient() has been called.
|
|
2607
2680
|
*/
|
|
2608
2681
|
|
|
2609
2682
|
/**
|
|
@@ -2663,34 +2736,38 @@ interface StreamOptions {
|
|
|
2663
2736
|
* - `agent.generate({ prompt })` for non-streaming one-shot generation
|
|
2664
2737
|
* - `agent.stream({ prompt })` for streaming real-time generation
|
|
2665
2738
|
*
|
|
2739
|
+
* **Auto-binding:** After calling `createClient()`, agents automatically
|
|
2740
|
+
* bind to the default client. No need for `blink.ai.createAgent()`.
|
|
2741
|
+
*
|
|
2666
2742
|
* @example
|
|
2667
2743
|
* ```ts
|
|
2668
|
-
* import { Agent, webSearch
|
|
2744
|
+
* import { createClient, Agent, webSearch } from '@blinkdotnew/sdk'
|
|
2745
|
+
*
|
|
2746
|
+
* // Initialize client once
|
|
2747
|
+
* createClient({ projectId: '...', secretKey: '...' })
|
|
2669
2748
|
*
|
|
2749
|
+
* // Create agent - auto-binds to default client
|
|
2670
2750
|
* const weatherAgent = new Agent({
|
|
2671
2751
|
* model: 'anthropic/claude-sonnet-4-20250514',
|
|
2672
2752
|
* system: 'You are a helpful weather assistant.',
|
|
2673
|
-
* tools: [webSearch
|
|
2753
|
+
* tools: [webSearch],
|
|
2674
2754
|
* maxSteps: 10,
|
|
2675
2755
|
* })
|
|
2676
2756
|
*
|
|
2677
|
-
* //
|
|
2757
|
+
* // Works immediately - no binding needed!
|
|
2678
2758
|
* const result = await weatherAgent.generate({
|
|
2679
2759
|
* prompt: 'What is the weather in San Francisco?',
|
|
2680
2760
|
* })
|
|
2681
2761
|
* console.log(result.text)
|
|
2682
|
-
*
|
|
2683
|
-
* // Streaming
|
|
2684
|
-
* const stream = await weatherAgent.stream({
|
|
2685
|
-
* prompt: 'Tell me about weather patterns',
|
|
2686
|
-
* })
|
|
2687
2762
|
* ```
|
|
2688
2763
|
*/
|
|
2689
2764
|
declare class Agent {
|
|
2690
2765
|
private httpClient;
|
|
2691
2766
|
private readonly config;
|
|
2692
2767
|
/**
|
|
2693
|
-
* Create a new Agent instance
|
|
2768
|
+
* Create a new Agent instance.
|
|
2769
|
+
* Auto-binds to default client if createClient() was called.
|
|
2770
|
+
*
|
|
2694
2771
|
* @param options - Agent configuration options
|
|
2695
2772
|
*/
|
|
2696
2773
|
constructor(options: AgentOptions);
|
|
@@ -3645,4 +3722,4 @@ declare const mediaTools: readonly ["generate_image", "edit_image", "generate_vi
|
|
|
3645
3722
|
*/
|
|
3646
3723
|
declare function serializeTools(tools: string[]): string[];
|
|
3647
3724
|
|
|
3648
|
-
export { type AISearchOptions, Agent, type AgentBilling, type AgentConfig, type AgentNonStreamMessagesRequest, type AgentNonStreamPromptRequest, type AgentOptions, type AgentRequest, type AgentResponse, type AgentStep, type AgentStreamRequest, type TokenUsage as AgentTokenUsage, type AnalyticsEvent, AsyncStorageAdapter, type AuthState, type AuthStateChangeCallback, type AuthTokens, type BlinkAI, BlinkAIImpl, type BlinkAnalytics, BlinkAnalyticsImpl, type BlinkClient, type BlinkClientConfig, BlinkConnectorError, type BlinkConnectors, BlinkConnectorsImpl, type BlinkData, BlinkDataImpl, BlinkDatabase, type BlinkRAG, BlinkRAGImpl, type BlinkRealtime, BlinkRealtimeChannel, BlinkRealtimeError, BlinkRealtimeImpl, type BlinkSandbox, BlinkSandboxImpl, type BlinkStorage, BlinkStorageImpl, BlinkTable, type BlinkTokenType, type BlinkUser, type ClientTool, type ConnectorApiKeyRequest, type ConnectorApiKeyResponse, type ConnectorAuthMode, type ConnectorExecuteRequest, type ConnectorExecuteResponse, type ConnectorProvider, type ConnectorStatusResponse, type ContextPolicy, type CreateCollectionOptions, type CreateOptions, type DataExtraction, type FileObject, type FilterCondition, type GenerateOptions, type ImageGenerationRequest, type ImageGenerationResponse, type JSONSchema, type ListDocumentsOptions, type Message, NoOpStorageAdapter, type ObjectGenerationRequest, type ObjectGenerationResponse, type PresenceUser, type QueryOptions, type RAGAISearchResult, type RAGAISearchSource, type RAGCollection, type RAGDocument, type RAGSearchResponse, type RAGSearchResult, type RealtimeChannel, type RealtimeGetMessagesOptions, type RealtimeMessage, type RealtimePublishOptions, type RealtimeSubscribeOptions, SANDBOX_TEMPLATES, type Sandbox, type SandboxConnectOptions, SandboxConnectionError, type SandboxCreateOptions, type SandboxTemplate, type SearchOptions, type SearchRequest, type SearchResponse, type SpeechGenerationRequest, type SpeechGenerationResponse, type StopCondition, type StorageAdapter, type StorageUploadOptions, type StorageUploadResponse, type StreamOptions, type TableOperations, type TextGenerationRequest, type TextGenerationResponse, type TokenIntrospectionResult, type TokenUsage$1 as TokenUsage, type ToolCall, type ToolResult, type TranscriptionRequest, type TranscriptionResponse, type UIMessage, type UIMessagePart, type UpdateOptions, type UploadOptions, type UpsertOptions, type WaitForReadyOptions, type WebBrowserModule, WebStorageAdapter, type WebhookTool, coreTools, createClient, dbDelete, dbGet, dbInsert, dbList, dbTools, dbUpdate, editImage, fetchUrl, generateImage, generateVideo, getDefaultStorageAdapter, getHost, globFileSearch, grep, imageToVideo, isBrowser, isDeno, isNode, isReactNative, isServer, isWeb, listDir, mediaTools, platform, ragSearch, ragTools, readFile, runCode, runTerminalCmd, sandboxTools, searchReplace, serializeTools, stepCountIs, storageCopy, storageDelete, storageDownload, storageList, storageMove, storagePublicUrl, storageTools, storageUpload, webSearch, writeFile };
|
|
3725
|
+
export { type AISearchOptions, Agent, type AgentBilling, type AgentConfig, type AgentNonStreamMessagesRequest, type AgentNonStreamPromptRequest, type AgentOptions, type AgentRequest, type AgentResponse, type AgentStep, type AgentStreamRequest, type TokenUsage as AgentTokenUsage, type AnalyticsEvent, AsyncStorageAdapter, type AuthState, type AuthStateChangeCallback, type AuthTokens, type BlinkAI, BlinkAIImpl, type BlinkAnalytics, BlinkAnalyticsImpl, type BlinkClient, type BlinkClientConfig, BlinkConnectorError, type BlinkConnectors, BlinkConnectorsImpl, type BlinkData, BlinkDataImpl, BlinkDatabase, type BlinkRAG, BlinkRAGImpl, type BlinkRealtime, BlinkRealtimeChannel, BlinkRealtimeError, BlinkRealtimeImpl, type BlinkSandbox, BlinkSandboxImpl, type BlinkStorage, BlinkStorageImpl, BlinkTable, type BlinkTokenType, type BlinkUser, type ClientTool, type ConnectorApiKeyRequest, type ConnectorApiKeyResponse, type ConnectorAuthMode, type ConnectorExecuteRequest, type ConnectorExecuteResponse, type ConnectorProvider, type ConnectorStatusResponse, type ContextPolicy, type CreateCollectionOptions, type CreateOptions, type DataExtraction, type FileObject, type FilterCondition, type GenerateOptions, type ImageGenerationRequest, type ImageGenerationResponse, type JSONSchema, type ListDocumentsOptions, type Message, NoOpStorageAdapter, type ObjectGenerationRequest, type ObjectGenerationResponse, type PresenceUser, type QueryOptions, type RAGAISearchResult, type RAGAISearchSource, type RAGCollection, type RAGDocument, type RAGSearchResponse, type RAGSearchResult, type RealtimeChannel, type RealtimeGetMessagesOptions, type RealtimeMessage, type RealtimePublishOptions, type RealtimeSubscribeOptions, SANDBOX_TEMPLATES, type Sandbox, type SandboxConnectOptions, SandboxConnectionError, type SandboxCreateOptions, type SandboxTemplate, type SearchOptions, type SearchRequest, type SearchResponse, type SpeechGenerationRequest, type SpeechGenerationResponse, type StopCondition, type StorageAdapter, type StorageUploadOptions, type StorageUploadResponse, type StreamOptions, type TableOperations, type TextGenerationRequest, type TextGenerationResponse, type TokenIntrospectionResult, type TokenUsage$1 as TokenUsage, type ToolCall, type ToolResult, type TranscriptionRequest, type TranscriptionResponse, type UIMessage, type UIMessagePart, type UpdateOptions, type UploadOptions, type UpsertOptions, type WaitForReadyOptions, type WebBrowserModule, WebStorageAdapter, type WebhookTool, coreTools, createClient, dbDelete, dbGet, dbInsert, dbList, dbTools, dbUpdate, editImage, fetchUrl, generateImage, generateVideo, getDefaultClient, getDefaultStorageAdapter, getHost, globFileSearch, grep, imageToVideo, isBrowser, isDeno, isNode, isReactNative, isServer, isWeb, listDir, mediaTools, platform, ragSearch, ragTools, readFile, runCode, runTerminalCmd, sandboxTools, searchReplace, serializeTools, stepCountIs, storageCopy, storageDelete, storageDownload, storageList, storageMove, storagePublicUrl, storageTools, storageUpload, webSearch, writeFile };
|
package/dist/index.d.ts
CHANGED
|
@@ -1145,6 +1145,20 @@ declare class HttpClient {
|
|
|
1145
1145
|
};
|
|
1146
1146
|
};
|
|
1147
1147
|
}, signal?: AbortSignal): Promise<Response>;
|
|
1148
|
+
/**
|
|
1149
|
+
* RAG AI Search streaming request
|
|
1150
|
+
* Returns raw Response for SSE streaming
|
|
1151
|
+
*/
|
|
1152
|
+
ragAiSearchStream(body: {
|
|
1153
|
+
collection_id?: string;
|
|
1154
|
+
collection_name?: string;
|
|
1155
|
+
query: string;
|
|
1156
|
+
model?: string;
|
|
1157
|
+
max_context_chunks?: number;
|
|
1158
|
+
score_threshold?: number;
|
|
1159
|
+
system_prompt?: string;
|
|
1160
|
+
stream: true;
|
|
1161
|
+
}, signal?: AbortSignal): Promise<Response>;
|
|
1148
1162
|
/**
|
|
1149
1163
|
* Data-specific requests
|
|
1150
1164
|
*/
|
|
@@ -2085,6 +2099,8 @@ interface AISearchOptions {
|
|
|
2085
2099
|
scoreThreshold?: number;
|
|
2086
2100
|
systemPrompt?: string;
|
|
2087
2101
|
stream?: boolean;
|
|
2102
|
+
/** AbortSignal for cancellation (streaming only) */
|
|
2103
|
+
signal?: AbortSignal;
|
|
2088
2104
|
}
|
|
2089
2105
|
interface ListDocumentsOptions {
|
|
2090
2106
|
collectionId?: string;
|
|
@@ -2228,6 +2244,13 @@ interface SandboxCreateOptions {
|
|
|
2228
2244
|
timeoutMs?: number;
|
|
2229
2245
|
/** Custom metadata for tracking */
|
|
2230
2246
|
metadata?: Record<string, string>;
|
|
2247
|
+
/**
|
|
2248
|
+
* Secret names to inject as environment variables.
|
|
2249
|
+
* Secrets are resolved server-side from project secrets vault.
|
|
2250
|
+
* Add secrets via Workspace > Secrets or request_secret tool.
|
|
2251
|
+
* @example ['ANTHROPIC_API_KEY', 'GITHUB_TOKEN']
|
|
2252
|
+
*/
|
|
2253
|
+
secrets?: string[];
|
|
2231
2254
|
}
|
|
2232
2255
|
interface SandboxConnectOptions {
|
|
2233
2256
|
/** Reset inactivity timeout in ms (default: 5 min) */
|
|
@@ -2290,6 +2313,23 @@ declare class BlinkSandboxImpl implements BlinkSandbox {
|
|
|
2290
2313
|
* Factory function and client class for the Blink SDK
|
|
2291
2314
|
*/
|
|
2292
2315
|
|
|
2316
|
+
/**
|
|
2317
|
+
* Get the default Blink client instance.
|
|
2318
|
+
* Returns the client created by createClient().
|
|
2319
|
+
*
|
|
2320
|
+
* @throws Error if createClient() hasn't been called yet
|
|
2321
|
+
* @returns The default BlinkClient instance
|
|
2322
|
+
*
|
|
2323
|
+
* @example
|
|
2324
|
+
* ```ts
|
|
2325
|
+
* // First, create client somewhere in your app
|
|
2326
|
+
* createClient({ projectId: '...', secretKey: '...' })
|
|
2327
|
+
*
|
|
2328
|
+
* // Later, get the default client
|
|
2329
|
+
* const client = getDefaultClient()
|
|
2330
|
+
* ```
|
|
2331
|
+
*/
|
|
2332
|
+
declare function getDefaultClient(): BlinkClientImpl;
|
|
2293
2333
|
interface BlinkClient {
|
|
2294
2334
|
auth: BlinkAuth;
|
|
2295
2335
|
db: BlinkDatabase;
|
|
@@ -2304,8 +2344,39 @@ interface BlinkClient {
|
|
|
2304
2344
|
rag: BlinkRAG;
|
|
2305
2345
|
sandbox: BlinkSandbox;
|
|
2306
2346
|
}
|
|
2347
|
+
declare class BlinkClientImpl implements BlinkClient {
|
|
2348
|
+
auth: BlinkAuth;
|
|
2349
|
+
db: BlinkDatabase;
|
|
2350
|
+
storage: BlinkStorage;
|
|
2351
|
+
ai: BlinkAI;
|
|
2352
|
+
data: BlinkData;
|
|
2353
|
+
realtime: BlinkRealtime;
|
|
2354
|
+
notifications: BlinkNotifications;
|
|
2355
|
+
analytics: BlinkAnalytics;
|
|
2356
|
+
connectors: BlinkConnectors;
|
|
2357
|
+
functions: BlinkFunctions;
|
|
2358
|
+
rag: BlinkRAG;
|
|
2359
|
+
sandbox: BlinkSandbox;
|
|
2360
|
+
/** @internal HTTP client for Agent auto-binding */
|
|
2361
|
+
_httpClient: HttpClient;
|
|
2362
|
+
constructor(config: BlinkClientConfig);
|
|
2363
|
+
}
|
|
2307
2364
|
/**
|
|
2308
|
-
* Create a new Blink client instance
|
|
2365
|
+
* Create a new Blink client instance.
|
|
2366
|
+
* This also sets the default client for Agent auto-binding.
|
|
2367
|
+
*
|
|
2368
|
+
* @example
|
|
2369
|
+
* ```ts
|
|
2370
|
+
* // Create client (call once in your app)
|
|
2371
|
+
* const blink = createClient({
|
|
2372
|
+
* projectId: 'my-project',
|
|
2373
|
+
* secretKey: 'sk_...',
|
|
2374
|
+
* })
|
|
2375
|
+
*
|
|
2376
|
+
* // Now Agent works without explicit binding
|
|
2377
|
+
* const agent = new Agent({ model: 'openai/gpt-4o' })
|
|
2378
|
+
* await agent.generate({ prompt: 'Hello!' })
|
|
2379
|
+
* ```
|
|
2309
2380
|
*/
|
|
2310
2381
|
declare function createClient(config: BlinkClientConfig): BlinkClient;
|
|
2311
2382
|
|
|
@@ -2604,6 +2675,8 @@ interface AgentResponse {
|
|
|
2604
2675
|
* - Create agent instance with config
|
|
2605
2676
|
* - Call agent.generate() for non-streaming
|
|
2606
2677
|
* - Call agent.stream() for streaming
|
|
2678
|
+
*
|
|
2679
|
+
* Auto-binds to default client when createClient() has been called.
|
|
2607
2680
|
*/
|
|
2608
2681
|
|
|
2609
2682
|
/**
|
|
@@ -2663,34 +2736,38 @@ interface StreamOptions {
|
|
|
2663
2736
|
* - `agent.generate({ prompt })` for non-streaming one-shot generation
|
|
2664
2737
|
* - `agent.stream({ prompt })` for streaming real-time generation
|
|
2665
2738
|
*
|
|
2739
|
+
* **Auto-binding:** After calling `createClient()`, agents automatically
|
|
2740
|
+
* bind to the default client. No need for `blink.ai.createAgent()`.
|
|
2741
|
+
*
|
|
2666
2742
|
* @example
|
|
2667
2743
|
* ```ts
|
|
2668
|
-
* import { Agent, webSearch
|
|
2744
|
+
* import { createClient, Agent, webSearch } from '@blinkdotnew/sdk'
|
|
2745
|
+
*
|
|
2746
|
+
* // Initialize client once
|
|
2747
|
+
* createClient({ projectId: '...', secretKey: '...' })
|
|
2669
2748
|
*
|
|
2749
|
+
* // Create agent - auto-binds to default client
|
|
2670
2750
|
* const weatherAgent = new Agent({
|
|
2671
2751
|
* model: 'anthropic/claude-sonnet-4-20250514',
|
|
2672
2752
|
* system: 'You are a helpful weather assistant.',
|
|
2673
|
-
* tools: [webSearch
|
|
2753
|
+
* tools: [webSearch],
|
|
2674
2754
|
* maxSteps: 10,
|
|
2675
2755
|
* })
|
|
2676
2756
|
*
|
|
2677
|
-
* //
|
|
2757
|
+
* // Works immediately - no binding needed!
|
|
2678
2758
|
* const result = await weatherAgent.generate({
|
|
2679
2759
|
* prompt: 'What is the weather in San Francisco?',
|
|
2680
2760
|
* })
|
|
2681
2761
|
* console.log(result.text)
|
|
2682
|
-
*
|
|
2683
|
-
* // Streaming
|
|
2684
|
-
* const stream = await weatherAgent.stream({
|
|
2685
|
-
* prompt: 'Tell me about weather patterns',
|
|
2686
|
-
* })
|
|
2687
2762
|
* ```
|
|
2688
2763
|
*/
|
|
2689
2764
|
declare class Agent {
|
|
2690
2765
|
private httpClient;
|
|
2691
2766
|
private readonly config;
|
|
2692
2767
|
/**
|
|
2693
|
-
* Create a new Agent instance
|
|
2768
|
+
* Create a new Agent instance.
|
|
2769
|
+
* Auto-binds to default client if createClient() was called.
|
|
2770
|
+
*
|
|
2694
2771
|
* @param options - Agent configuration options
|
|
2695
2772
|
*/
|
|
2696
2773
|
constructor(options: AgentOptions);
|
|
@@ -3645,4 +3722,4 @@ declare const mediaTools: readonly ["generate_image", "edit_image", "generate_vi
|
|
|
3645
3722
|
*/
|
|
3646
3723
|
declare function serializeTools(tools: string[]): string[];
|
|
3647
3724
|
|
|
3648
|
-
export { type AISearchOptions, Agent, type AgentBilling, type AgentConfig, type AgentNonStreamMessagesRequest, type AgentNonStreamPromptRequest, type AgentOptions, type AgentRequest, type AgentResponse, type AgentStep, type AgentStreamRequest, type TokenUsage as AgentTokenUsage, type AnalyticsEvent, AsyncStorageAdapter, type AuthState, type AuthStateChangeCallback, type AuthTokens, type BlinkAI, BlinkAIImpl, type BlinkAnalytics, BlinkAnalyticsImpl, type BlinkClient, type BlinkClientConfig, BlinkConnectorError, type BlinkConnectors, BlinkConnectorsImpl, type BlinkData, BlinkDataImpl, BlinkDatabase, type BlinkRAG, BlinkRAGImpl, type BlinkRealtime, BlinkRealtimeChannel, BlinkRealtimeError, BlinkRealtimeImpl, type BlinkSandbox, BlinkSandboxImpl, type BlinkStorage, BlinkStorageImpl, BlinkTable, type BlinkTokenType, type BlinkUser, type ClientTool, type ConnectorApiKeyRequest, type ConnectorApiKeyResponse, type ConnectorAuthMode, type ConnectorExecuteRequest, type ConnectorExecuteResponse, type ConnectorProvider, type ConnectorStatusResponse, type ContextPolicy, type CreateCollectionOptions, type CreateOptions, type DataExtraction, type FileObject, type FilterCondition, type GenerateOptions, type ImageGenerationRequest, type ImageGenerationResponse, type JSONSchema, type ListDocumentsOptions, type Message, NoOpStorageAdapter, type ObjectGenerationRequest, type ObjectGenerationResponse, type PresenceUser, type QueryOptions, type RAGAISearchResult, type RAGAISearchSource, type RAGCollection, type RAGDocument, type RAGSearchResponse, type RAGSearchResult, type RealtimeChannel, type RealtimeGetMessagesOptions, type RealtimeMessage, type RealtimePublishOptions, type RealtimeSubscribeOptions, SANDBOX_TEMPLATES, type Sandbox, type SandboxConnectOptions, SandboxConnectionError, type SandboxCreateOptions, type SandboxTemplate, type SearchOptions, type SearchRequest, type SearchResponse, type SpeechGenerationRequest, type SpeechGenerationResponse, type StopCondition, type StorageAdapter, type StorageUploadOptions, type StorageUploadResponse, type StreamOptions, type TableOperations, type TextGenerationRequest, type TextGenerationResponse, type TokenIntrospectionResult, type TokenUsage$1 as TokenUsage, type ToolCall, type ToolResult, type TranscriptionRequest, type TranscriptionResponse, type UIMessage, type UIMessagePart, type UpdateOptions, type UploadOptions, type UpsertOptions, type WaitForReadyOptions, type WebBrowserModule, WebStorageAdapter, type WebhookTool, coreTools, createClient, dbDelete, dbGet, dbInsert, dbList, dbTools, dbUpdate, editImage, fetchUrl, generateImage, generateVideo, getDefaultStorageAdapter, getHost, globFileSearch, grep, imageToVideo, isBrowser, isDeno, isNode, isReactNative, isServer, isWeb, listDir, mediaTools, platform, ragSearch, ragTools, readFile, runCode, runTerminalCmd, sandboxTools, searchReplace, serializeTools, stepCountIs, storageCopy, storageDelete, storageDownload, storageList, storageMove, storagePublicUrl, storageTools, storageUpload, webSearch, writeFile };
|
|
3725
|
+
export { type AISearchOptions, Agent, type AgentBilling, type AgentConfig, type AgentNonStreamMessagesRequest, type AgentNonStreamPromptRequest, type AgentOptions, type AgentRequest, type AgentResponse, type AgentStep, type AgentStreamRequest, type TokenUsage as AgentTokenUsage, type AnalyticsEvent, AsyncStorageAdapter, type AuthState, type AuthStateChangeCallback, type AuthTokens, type BlinkAI, BlinkAIImpl, type BlinkAnalytics, BlinkAnalyticsImpl, type BlinkClient, type BlinkClientConfig, BlinkConnectorError, type BlinkConnectors, BlinkConnectorsImpl, type BlinkData, BlinkDataImpl, BlinkDatabase, type BlinkRAG, BlinkRAGImpl, type BlinkRealtime, BlinkRealtimeChannel, BlinkRealtimeError, BlinkRealtimeImpl, type BlinkSandbox, BlinkSandboxImpl, type BlinkStorage, BlinkStorageImpl, BlinkTable, type BlinkTokenType, type BlinkUser, type ClientTool, type ConnectorApiKeyRequest, type ConnectorApiKeyResponse, type ConnectorAuthMode, type ConnectorExecuteRequest, type ConnectorExecuteResponse, type ConnectorProvider, type ConnectorStatusResponse, type ContextPolicy, type CreateCollectionOptions, type CreateOptions, type DataExtraction, type FileObject, type FilterCondition, type GenerateOptions, type ImageGenerationRequest, type ImageGenerationResponse, type JSONSchema, type ListDocumentsOptions, type Message, NoOpStorageAdapter, type ObjectGenerationRequest, type ObjectGenerationResponse, type PresenceUser, type QueryOptions, type RAGAISearchResult, type RAGAISearchSource, type RAGCollection, type RAGDocument, type RAGSearchResponse, type RAGSearchResult, type RealtimeChannel, type RealtimeGetMessagesOptions, type RealtimeMessage, type RealtimePublishOptions, type RealtimeSubscribeOptions, SANDBOX_TEMPLATES, type Sandbox, type SandboxConnectOptions, SandboxConnectionError, type SandboxCreateOptions, type SandboxTemplate, type SearchOptions, type SearchRequest, type SearchResponse, type SpeechGenerationRequest, type SpeechGenerationResponse, type StopCondition, type StorageAdapter, type StorageUploadOptions, type StorageUploadResponse, type StreamOptions, type TableOperations, type TextGenerationRequest, type TextGenerationResponse, type TokenIntrospectionResult, type TokenUsage$1 as TokenUsage, type ToolCall, type ToolResult, type TranscriptionRequest, type TranscriptionResponse, type UIMessage, type UIMessagePart, type UpdateOptions, type UploadOptions, type UpsertOptions, type WaitForReadyOptions, type WebBrowserModule, WebStorageAdapter, type WebhookTool, coreTools, createClient, dbDelete, dbGet, dbInsert, dbList, dbTools, dbUpdate, editImage, fetchUrl, generateImage, generateVideo, getDefaultClient, getDefaultStorageAdapter, getHost, globFileSearch, grep, imageToVideo, isBrowser, isDeno, isNode, isReactNative, isServer, isWeb, listDir, mediaTools, platform, ragSearch, ragTools, readFile, runCode, runTerminalCmd, sandboxTools, searchReplace, serializeTools, stepCountIs, storageCopy, storageDelete, storageDownload, storageList, storageMove, storagePublicUrl, storageTools, storageUpload, webSearch, writeFile };
|
package/dist/index.js
CHANGED
|
@@ -3503,6 +3503,29 @@ var HttpClient = class {
|
|
|
3503
3503
|
}
|
|
3504
3504
|
return response;
|
|
3505
3505
|
}
|
|
3506
|
+
/**
|
|
3507
|
+
* RAG AI Search streaming request
|
|
3508
|
+
* Returns raw Response for SSE streaming
|
|
3509
|
+
*/
|
|
3510
|
+
async ragAiSearchStream(body, signal) {
|
|
3511
|
+
const url = this.buildUrl(`/api/rag/${this.projectId}/ai-search`);
|
|
3512
|
+
const token = this.getValidToken ? await this.getValidToken() : this.getToken();
|
|
3513
|
+
const headers = {
|
|
3514
|
+
"Content-Type": "application/json"
|
|
3515
|
+
};
|
|
3516
|
+
const auth = this.getAuthorizationHeader(url, token);
|
|
3517
|
+
if (auth) headers.Authorization = auth;
|
|
3518
|
+
const response = await fetch(url, {
|
|
3519
|
+
method: "POST",
|
|
3520
|
+
headers,
|
|
3521
|
+
body: JSON.stringify(body),
|
|
3522
|
+
signal
|
|
3523
|
+
});
|
|
3524
|
+
if (!response.ok) {
|
|
3525
|
+
await this.handleErrorResponse(response);
|
|
3526
|
+
}
|
|
3527
|
+
return response;
|
|
3528
|
+
}
|
|
3506
3529
|
/**
|
|
3507
3530
|
* Data-specific requests
|
|
3508
3531
|
*/
|
|
@@ -6431,7 +6454,9 @@ var Agent = class {
|
|
|
6431
6454
|
httpClient = null;
|
|
6432
6455
|
config;
|
|
6433
6456
|
/**
|
|
6434
|
-
* Create a new Agent instance
|
|
6457
|
+
* Create a new Agent instance.
|
|
6458
|
+
* Auto-binds to default client if createClient() was called.
|
|
6459
|
+
*
|
|
6435
6460
|
* @param options - Agent configuration options
|
|
6436
6461
|
*/
|
|
6437
6462
|
constructor(options) {
|
|
@@ -6439,6 +6464,10 @@ var Agent = class {
|
|
|
6439
6464
|
throw new BlinkAIError("Agent model is required");
|
|
6440
6465
|
}
|
|
6441
6466
|
this.config = options;
|
|
6467
|
+
try {
|
|
6468
|
+
this.httpClient = _getDefaultHttpClient();
|
|
6469
|
+
} catch {
|
|
6470
|
+
}
|
|
6442
6471
|
}
|
|
6443
6472
|
/**
|
|
6444
6473
|
* Internal: Set the HTTP client (called by BlinkClient)
|
|
@@ -6481,7 +6510,7 @@ var Agent = class {
|
|
|
6481
6510
|
async generate(options) {
|
|
6482
6511
|
if (!this.httpClient) {
|
|
6483
6512
|
throw new BlinkAIError(
|
|
6484
|
-
"Agent not initialized.
|
|
6513
|
+
"Agent not initialized. Call createClient() first, or use useAgent() in React."
|
|
6485
6514
|
);
|
|
6486
6515
|
}
|
|
6487
6516
|
if (!options.prompt && !options.messages) {
|
|
@@ -6538,7 +6567,7 @@ var Agent = class {
|
|
|
6538
6567
|
async stream(options) {
|
|
6539
6568
|
if (!this.httpClient) {
|
|
6540
6569
|
throw new BlinkAIError(
|
|
6541
|
-
"Agent not initialized.
|
|
6570
|
+
"Agent not initialized. Call createClient() first, or use useAgent() in React."
|
|
6542
6571
|
);
|
|
6543
6572
|
}
|
|
6544
6573
|
if (!options.prompt && !options.messages) {
|
|
@@ -9084,7 +9113,8 @@ var BlinkRAGImpl = class {
|
|
|
9084
9113
|
stream: options.stream
|
|
9085
9114
|
});
|
|
9086
9115
|
if (options.stream) {
|
|
9087
|
-
|
|
9116
|
+
const response2 = await this.httpClient.ragAiSearchStream(body, options.signal);
|
|
9117
|
+
return response2.body;
|
|
9088
9118
|
}
|
|
9089
9119
|
const response = await this.httpClient.post(this.url("/ai-search"), body);
|
|
9090
9120
|
return convertAISearchResult(response.data);
|
|
@@ -9149,7 +9179,8 @@ var BlinkSandboxImpl = class {
|
|
|
9149
9179
|
const body = {
|
|
9150
9180
|
template: options.template,
|
|
9151
9181
|
timeout_ms: options.timeoutMs,
|
|
9152
|
-
metadata: options.metadata
|
|
9182
|
+
metadata: options.metadata,
|
|
9183
|
+
secrets: options.secrets
|
|
9153
9184
|
};
|
|
9154
9185
|
const response = await this.httpClient.post(this.url("/create"), body);
|
|
9155
9186
|
const { id, template, host_pattern } = response.data;
|
|
@@ -9187,6 +9218,18 @@ var BlinkSandboxImpl = class {
|
|
|
9187
9218
|
};
|
|
9188
9219
|
|
|
9189
9220
|
// src/client.ts
|
|
9221
|
+
var defaultClient = null;
|
|
9222
|
+
function getDefaultClient() {
|
|
9223
|
+
if (!defaultClient) {
|
|
9224
|
+
throw new Error(
|
|
9225
|
+
"No Blink client initialized. Call createClient() first before using Agent or other SDK features."
|
|
9226
|
+
);
|
|
9227
|
+
}
|
|
9228
|
+
return defaultClient;
|
|
9229
|
+
}
|
|
9230
|
+
function _getDefaultHttpClient() {
|
|
9231
|
+
return getDefaultClient()._httpClient;
|
|
9232
|
+
}
|
|
9190
9233
|
var BlinkClientImpl = class {
|
|
9191
9234
|
auth;
|
|
9192
9235
|
db;
|
|
@@ -9200,32 +9243,33 @@ var BlinkClientImpl = class {
|
|
|
9200
9243
|
functions;
|
|
9201
9244
|
rag;
|
|
9202
9245
|
sandbox;
|
|
9203
|
-
|
|
9246
|
+
/** @internal HTTP client for Agent auto-binding */
|
|
9247
|
+
_httpClient;
|
|
9204
9248
|
constructor(config) {
|
|
9205
9249
|
if ((config.secretKey || config.serviceToken) && isBrowser) {
|
|
9206
9250
|
throw new Error("secretKey/serviceToken is server-only. Do not provide it in browser/React Native clients.");
|
|
9207
9251
|
}
|
|
9208
9252
|
this.auth = new BlinkAuth(config);
|
|
9209
|
-
this.
|
|
9253
|
+
this._httpClient = new HttpClient(
|
|
9210
9254
|
config,
|
|
9211
9255
|
() => this.auth.getToken(),
|
|
9212
9256
|
() => this.auth.getValidToken()
|
|
9213
9257
|
);
|
|
9214
|
-
this.db = new BlinkDatabase(this.
|
|
9215
|
-
this.storage = new BlinkStorageImpl(this.
|
|
9216
|
-
this.ai = new BlinkAIImpl(this.
|
|
9217
|
-
this.data = new BlinkDataImpl(this.
|
|
9218
|
-
this.realtime = new BlinkRealtimeImpl(this.
|
|
9219
|
-
this.notifications = new BlinkNotificationsImpl(this.
|
|
9220
|
-
this.analytics = new BlinkAnalyticsImpl(this.
|
|
9221
|
-
this.connectors = new BlinkConnectorsImpl(this.
|
|
9258
|
+
this.db = new BlinkDatabase(this._httpClient);
|
|
9259
|
+
this.storage = new BlinkStorageImpl(this._httpClient);
|
|
9260
|
+
this.ai = new BlinkAIImpl(this._httpClient);
|
|
9261
|
+
this.data = new BlinkDataImpl(this._httpClient, config.projectId);
|
|
9262
|
+
this.realtime = new BlinkRealtimeImpl(this._httpClient, config.projectId);
|
|
9263
|
+
this.notifications = new BlinkNotificationsImpl(this._httpClient);
|
|
9264
|
+
this.analytics = new BlinkAnalyticsImpl(this._httpClient, config.projectId);
|
|
9265
|
+
this.connectors = new BlinkConnectorsImpl(this._httpClient);
|
|
9222
9266
|
this.functions = new BlinkFunctionsImpl(
|
|
9223
|
-
this.
|
|
9267
|
+
this._httpClient,
|
|
9224
9268
|
config.projectId,
|
|
9225
9269
|
() => this.auth.getValidToken()
|
|
9226
9270
|
);
|
|
9227
|
-
this.rag = new BlinkRAGImpl(this.
|
|
9228
|
-
this.sandbox = new BlinkSandboxImpl(this.
|
|
9271
|
+
this.rag = new BlinkRAGImpl(this._httpClient);
|
|
9272
|
+
this.sandbox = new BlinkSandboxImpl(this._httpClient);
|
|
9229
9273
|
this.auth.onAuthStateChanged((state) => {
|
|
9230
9274
|
if (state.isAuthenticated && state.user) {
|
|
9231
9275
|
this.analytics.setUserId(state.user.id);
|
|
@@ -9241,7 +9285,9 @@ function createClient(config) {
|
|
|
9241
9285
|
if (!config.projectId) {
|
|
9242
9286
|
throw new Error("projectId is required");
|
|
9243
9287
|
}
|
|
9244
|
-
|
|
9288
|
+
const client = new BlinkClientImpl(config);
|
|
9289
|
+
defaultClient = client;
|
|
9290
|
+
return client;
|
|
9245
9291
|
}
|
|
9246
9292
|
|
|
9247
9293
|
exports.Agent = Agent;
|
|
@@ -9273,6 +9319,7 @@ exports.editImage = editImage;
|
|
|
9273
9319
|
exports.fetchUrl = fetchUrl;
|
|
9274
9320
|
exports.generateImage = generateImage;
|
|
9275
9321
|
exports.generateVideo = generateVideo;
|
|
9322
|
+
exports.getDefaultClient = getDefaultClient;
|
|
9276
9323
|
exports.getDefaultStorageAdapter = getDefaultStorageAdapter;
|
|
9277
9324
|
exports.getHost = getHost;
|
|
9278
9325
|
exports.globFileSearch = globFileSearch;
|
package/dist/index.mjs
CHANGED
|
@@ -3501,6 +3501,29 @@ var HttpClient = class {
|
|
|
3501
3501
|
}
|
|
3502
3502
|
return response;
|
|
3503
3503
|
}
|
|
3504
|
+
/**
|
|
3505
|
+
* RAG AI Search streaming request
|
|
3506
|
+
* Returns raw Response for SSE streaming
|
|
3507
|
+
*/
|
|
3508
|
+
async ragAiSearchStream(body, signal) {
|
|
3509
|
+
const url = this.buildUrl(`/api/rag/${this.projectId}/ai-search`);
|
|
3510
|
+
const token = this.getValidToken ? await this.getValidToken() : this.getToken();
|
|
3511
|
+
const headers = {
|
|
3512
|
+
"Content-Type": "application/json"
|
|
3513
|
+
};
|
|
3514
|
+
const auth = this.getAuthorizationHeader(url, token);
|
|
3515
|
+
if (auth) headers.Authorization = auth;
|
|
3516
|
+
const response = await fetch(url, {
|
|
3517
|
+
method: "POST",
|
|
3518
|
+
headers,
|
|
3519
|
+
body: JSON.stringify(body),
|
|
3520
|
+
signal
|
|
3521
|
+
});
|
|
3522
|
+
if (!response.ok) {
|
|
3523
|
+
await this.handleErrorResponse(response);
|
|
3524
|
+
}
|
|
3525
|
+
return response;
|
|
3526
|
+
}
|
|
3504
3527
|
/**
|
|
3505
3528
|
* Data-specific requests
|
|
3506
3529
|
*/
|
|
@@ -6429,7 +6452,9 @@ var Agent = class {
|
|
|
6429
6452
|
httpClient = null;
|
|
6430
6453
|
config;
|
|
6431
6454
|
/**
|
|
6432
|
-
* Create a new Agent instance
|
|
6455
|
+
* Create a new Agent instance.
|
|
6456
|
+
* Auto-binds to default client if createClient() was called.
|
|
6457
|
+
*
|
|
6433
6458
|
* @param options - Agent configuration options
|
|
6434
6459
|
*/
|
|
6435
6460
|
constructor(options) {
|
|
@@ -6437,6 +6462,10 @@ var Agent = class {
|
|
|
6437
6462
|
throw new BlinkAIError("Agent model is required");
|
|
6438
6463
|
}
|
|
6439
6464
|
this.config = options;
|
|
6465
|
+
try {
|
|
6466
|
+
this.httpClient = _getDefaultHttpClient();
|
|
6467
|
+
} catch {
|
|
6468
|
+
}
|
|
6440
6469
|
}
|
|
6441
6470
|
/**
|
|
6442
6471
|
* Internal: Set the HTTP client (called by BlinkClient)
|
|
@@ -6479,7 +6508,7 @@ var Agent = class {
|
|
|
6479
6508
|
async generate(options) {
|
|
6480
6509
|
if (!this.httpClient) {
|
|
6481
6510
|
throw new BlinkAIError(
|
|
6482
|
-
"Agent not initialized.
|
|
6511
|
+
"Agent not initialized. Call createClient() first, or use useAgent() in React."
|
|
6483
6512
|
);
|
|
6484
6513
|
}
|
|
6485
6514
|
if (!options.prompt && !options.messages) {
|
|
@@ -6536,7 +6565,7 @@ var Agent = class {
|
|
|
6536
6565
|
async stream(options) {
|
|
6537
6566
|
if (!this.httpClient) {
|
|
6538
6567
|
throw new BlinkAIError(
|
|
6539
|
-
"Agent not initialized.
|
|
6568
|
+
"Agent not initialized. Call createClient() first, or use useAgent() in React."
|
|
6540
6569
|
);
|
|
6541
6570
|
}
|
|
6542
6571
|
if (!options.prompt && !options.messages) {
|
|
@@ -9082,7 +9111,8 @@ var BlinkRAGImpl = class {
|
|
|
9082
9111
|
stream: options.stream
|
|
9083
9112
|
});
|
|
9084
9113
|
if (options.stream) {
|
|
9085
|
-
|
|
9114
|
+
const response2 = await this.httpClient.ragAiSearchStream(body, options.signal);
|
|
9115
|
+
return response2.body;
|
|
9086
9116
|
}
|
|
9087
9117
|
const response = await this.httpClient.post(this.url("/ai-search"), body);
|
|
9088
9118
|
return convertAISearchResult(response.data);
|
|
@@ -9147,7 +9177,8 @@ var BlinkSandboxImpl = class {
|
|
|
9147
9177
|
const body = {
|
|
9148
9178
|
template: options.template,
|
|
9149
9179
|
timeout_ms: options.timeoutMs,
|
|
9150
|
-
metadata: options.metadata
|
|
9180
|
+
metadata: options.metadata,
|
|
9181
|
+
secrets: options.secrets
|
|
9151
9182
|
};
|
|
9152
9183
|
const response = await this.httpClient.post(this.url("/create"), body);
|
|
9153
9184
|
const { id, template, host_pattern } = response.data;
|
|
@@ -9185,6 +9216,18 @@ var BlinkSandboxImpl = class {
|
|
|
9185
9216
|
};
|
|
9186
9217
|
|
|
9187
9218
|
// src/client.ts
|
|
9219
|
+
var defaultClient = null;
|
|
9220
|
+
function getDefaultClient() {
|
|
9221
|
+
if (!defaultClient) {
|
|
9222
|
+
throw new Error(
|
|
9223
|
+
"No Blink client initialized. Call createClient() first before using Agent or other SDK features."
|
|
9224
|
+
);
|
|
9225
|
+
}
|
|
9226
|
+
return defaultClient;
|
|
9227
|
+
}
|
|
9228
|
+
function _getDefaultHttpClient() {
|
|
9229
|
+
return getDefaultClient()._httpClient;
|
|
9230
|
+
}
|
|
9188
9231
|
var BlinkClientImpl = class {
|
|
9189
9232
|
auth;
|
|
9190
9233
|
db;
|
|
@@ -9198,32 +9241,33 @@ var BlinkClientImpl = class {
|
|
|
9198
9241
|
functions;
|
|
9199
9242
|
rag;
|
|
9200
9243
|
sandbox;
|
|
9201
|
-
|
|
9244
|
+
/** @internal HTTP client for Agent auto-binding */
|
|
9245
|
+
_httpClient;
|
|
9202
9246
|
constructor(config) {
|
|
9203
9247
|
if ((config.secretKey || config.serviceToken) && isBrowser) {
|
|
9204
9248
|
throw new Error("secretKey/serviceToken is server-only. Do not provide it in browser/React Native clients.");
|
|
9205
9249
|
}
|
|
9206
9250
|
this.auth = new BlinkAuth(config);
|
|
9207
|
-
this.
|
|
9251
|
+
this._httpClient = new HttpClient(
|
|
9208
9252
|
config,
|
|
9209
9253
|
() => this.auth.getToken(),
|
|
9210
9254
|
() => this.auth.getValidToken()
|
|
9211
9255
|
);
|
|
9212
|
-
this.db = new BlinkDatabase(this.
|
|
9213
|
-
this.storage = new BlinkStorageImpl(this.
|
|
9214
|
-
this.ai = new BlinkAIImpl(this.
|
|
9215
|
-
this.data = new BlinkDataImpl(this.
|
|
9216
|
-
this.realtime = new BlinkRealtimeImpl(this.
|
|
9217
|
-
this.notifications = new BlinkNotificationsImpl(this.
|
|
9218
|
-
this.analytics = new BlinkAnalyticsImpl(this.
|
|
9219
|
-
this.connectors = new BlinkConnectorsImpl(this.
|
|
9256
|
+
this.db = new BlinkDatabase(this._httpClient);
|
|
9257
|
+
this.storage = new BlinkStorageImpl(this._httpClient);
|
|
9258
|
+
this.ai = new BlinkAIImpl(this._httpClient);
|
|
9259
|
+
this.data = new BlinkDataImpl(this._httpClient, config.projectId);
|
|
9260
|
+
this.realtime = new BlinkRealtimeImpl(this._httpClient, config.projectId);
|
|
9261
|
+
this.notifications = new BlinkNotificationsImpl(this._httpClient);
|
|
9262
|
+
this.analytics = new BlinkAnalyticsImpl(this._httpClient, config.projectId);
|
|
9263
|
+
this.connectors = new BlinkConnectorsImpl(this._httpClient);
|
|
9220
9264
|
this.functions = new BlinkFunctionsImpl(
|
|
9221
|
-
this.
|
|
9265
|
+
this._httpClient,
|
|
9222
9266
|
config.projectId,
|
|
9223
9267
|
() => this.auth.getValidToken()
|
|
9224
9268
|
);
|
|
9225
|
-
this.rag = new BlinkRAGImpl(this.
|
|
9226
|
-
this.sandbox = new BlinkSandboxImpl(this.
|
|
9269
|
+
this.rag = new BlinkRAGImpl(this._httpClient);
|
|
9270
|
+
this.sandbox = new BlinkSandboxImpl(this._httpClient);
|
|
9227
9271
|
this.auth.onAuthStateChanged((state) => {
|
|
9228
9272
|
if (state.isAuthenticated && state.user) {
|
|
9229
9273
|
this.analytics.setUserId(state.user.id);
|
|
@@ -9239,9 +9283,11 @@ function createClient(config) {
|
|
|
9239
9283
|
if (!config.projectId) {
|
|
9240
9284
|
throw new Error("projectId is required");
|
|
9241
9285
|
}
|
|
9242
|
-
|
|
9286
|
+
const client = new BlinkClientImpl(config);
|
|
9287
|
+
defaultClient = client;
|
|
9288
|
+
return client;
|
|
9243
9289
|
}
|
|
9244
9290
|
|
|
9245
|
-
export { Agent, AsyncStorageAdapter, BlinkAIImpl, BlinkAnalyticsImpl, BlinkConnectorsImpl, BlinkDataImpl, BlinkDatabase, BlinkRAGImpl, BlinkRealtimeChannel, BlinkRealtimeImpl, BlinkSandboxImpl, BlinkStorageImpl, BlinkTable, NoOpStorageAdapter, SANDBOX_TEMPLATES, SandboxConnectionError, WebStorageAdapter, coreTools, createClient, dbDelete, dbGet, dbInsert, dbList, dbTools, dbUpdate, editImage, fetchUrl, generateImage, generateVideo, getDefaultStorageAdapter, getHost, globFileSearch, grep, imageToVideo, isBrowser, isDeno, isNode, isReactNative, isServer, isWeb, listDir, mediaTools, platform, ragSearch, ragTools, readFile, runCode, runTerminalCmd, sandboxTools, searchReplace, serializeTools, stepCountIs, storageCopy, storageDelete, storageDownload, storageList, storageMove, storagePublicUrl, storageTools, storageUpload, webSearch, writeFile };
|
|
9291
|
+
export { Agent, AsyncStorageAdapter, BlinkAIImpl, BlinkAnalyticsImpl, BlinkConnectorsImpl, BlinkDataImpl, BlinkDatabase, BlinkRAGImpl, BlinkRealtimeChannel, BlinkRealtimeImpl, BlinkSandboxImpl, BlinkStorageImpl, BlinkTable, NoOpStorageAdapter, SANDBOX_TEMPLATES, SandboxConnectionError, WebStorageAdapter, coreTools, createClient, dbDelete, dbGet, dbInsert, dbList, dbTools, dbUpdate, editImage, fetchUrl, generateImage, generateVideo, getDefaultClient, getDefaultStorageAdapter, getHost, globFileSearch, grep, imageToVideo, isBrowser, isDeno, isNode, isReactNative, isServer, isWeb, listDir, mediaTools, platform, ragSearch, ragTools, readFile, runCode, runTerminalCmd, sandboxTools, searchReplace, serializeTools, stepCountIs, storageCopy, storageDelete, storageDownload, storageList, storageMove, storagePublicUrl, storageTools, storageUpload, webSearch, writeFile };
|
|
9246
9292
|
//# sourceMappingURL=index.mjs.map
|
|
9247
9293
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED