@blinkdotnew/sdk 2.3.3 → 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 +72 -11
- package/dist/index.d.ts +72 -11
- package/dist/index.js +41 -18
- package/dist/index.mjs +41 -19
- package/package.json +4 -2
package/dist/index.d.mts
CHANGED
|
@@ -2244,6 +2244,13 @@ interface SandboxCreateOptions {
|
|
|
2244
2244
|
timeoutMs?: number;
|
|
2245
2245
|
/** Custom metadata for tracking */
|
|
2246
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[];
|
|
2247
2254
|
}
|
|
2248
2255
|
interface SandboxConnectOptions {
|
|
2249
2256
|
/** Reset inactivity timeout in ms (default: 5 min) */
|
|
@@ -2306,6 +2313,23 @@ declare class BlinkSandboxImpl implements BlinkSandbox {
|
|
|
2306
2313
|
* Factory function and client class for the Blink SDK
|
|
2307
2314
|
*/
|
|
2308
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;
|
|
2309
2333
|
interface BlinkClient {
|
|
2310
2334
|
auth: BlinkAuth;
|
|
2311
2335
|
db: BlinkDatabase;
|
|
@@ -2320,8 +2344,39 @@ interface BlinkClient {
|
|
|
2320
2344
|
rag: BlinkRAG;
|
|
2321
2345
|
sandbox: BlinkSandbox;
|
|
2322
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
|
+
}
|
|
2323
2364
|
/**
|
|
2324
|
-
* 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
|
+
* ```
|
|
2325
2380
|
*/
|
|
2326
2381
|
declare function createClient(config: BlinkClientConfig): BlinkClient;
|
|
2327
2382
|
|
|
@@ -2620,6 +2675,8 @@ interface AgentResponse {
|
|
|
2620
2675
|
* - Create agent instance with config
|
|
2621
2676
|
* - Call agent.generate() for non-streaming
|
|
2622
2677
|
* - Call agent.stream() for streaming
|
|
2678
|
+
*
|
|
2679
|
+
* Auto-binds to default client when createClient() has been called.
|
|
2623
2680
|
*/
|
|
2624
2681
|
|
|
2625
2682
|
/**
|
|
@@ -2679,34 +2736,38 @@ interface StreamOptions {
|
|
|
2679
2736
|
* - `agent.generate({ prompt })` for non-streaming one-shot generation
|
|
2680
2737
|
* - `agent.stream({ prompt })` for streaming real-time generation
|
|
2681
2738
|
*
|
|
2739
|
+
* **Auto-binding:** After calling `createClient()`, agents automatically
|
|
2740
|
+
* bind to the default client. No need for `blink.ai.createAgent()`.
|
|
2741
|
+
*
|
|
2682
2742
|
* @example
|
|
2683
2743
|
* ```ts
|
|
2684
|
-
* import { Agent, webSearch
|
|
2744
|
+
* import { createClient, Agent, webSearch } from '@blinkdotnew/sdk'
|
|
2685
2745
|
*
|
|
2746
|
+
* // Initialize client once
|
|
2747
|
+
* createClient({ projectId: '...', secretKey: '...' })
|
|
2748
|
+
*
|
|
2749
|
+
* // Create agent - auto-binds to default client
|
|
2686
2750
|
* const weatherAgent = new Agent({
|
|
2687
2751
|
* model: 'anthropic/claude-sonnet-4-20250514',
|
|
2688
2752
|
* system: 'You are a helpful weather assistant.',
|
|
2689
|
-
* tools: [webSearch
|
|
2753
|
+
* tools: [webSearch],
|
|
2690
2754
|
* maxSteps: 10,
|
|
2691
2755
|
* })
|
|
2692
2756
|
*
|
|
2693
|
-
* //
|
|
2757
|
+
* // Works immediately - no binding needed!
|
|
2694
2758
|
* const result = await weatherAgent.generate({
|
|
2695
2759
|
* prompt: 'What is the weather in San Francisco?',
|
|
2696
2760
|
* })
|
|
2697
2761
|
* console.log(result.text)
|
|
2698
|
-
*
|
|
2699
|
-
* // Streaming
|
|
2700
|
-
* const stream = await weatherAgent.stream({
|
|
2701
|
-
* prompt: 'Tell me about weather patterns',
|
|
2702
|
-
* })
|
|
2703
2762
|
* ```
|
|
2704
2763
|
*/
|
|
2705
2764
|
declare class Agent {
|
|
2706
2765
|
private httpClient;
|
|
2707
2766
|
private readonly config;
|
|
2708
2767
|
/**
|
|
2709
|
-
* Create a new Agent instance
|
|
2768
|
+
* Create a new Agent instance.
|
|
2769
|
+
* Auto-binds to default client if createClient() was called.
|
|
2770
|
+
*
|
|
2710
2771
|
* @param options - Agent configuration options
|
|
2711
2772
|
*/
|
|
2712
2773
|
constructor(options: AgentOptions);
|
|
@@ -3661,4 +3722,4 @@ declare const mediaTools: readonly ["generate_image", "edit_image", "generate_vi
|
|
|
3661
3722
|
*/
|
|
3662
3723
|
declare function serializeTools(tools: string[]): string[];
|
|
3663
3724
|
|
|
3664
|
-
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
|
@@ -2244,6 +2244,13 @@ interface SandboxCreateOptions {
|
|
|
2244
2244
|
timeoutMs?: number;
|
|
2245
2245
|
/** Custom metadata for tracking */
|
|
2246
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[];
|
|
2247
2254
|
}
|
|
2248
2255
|
interface SandboxConnectOptions {
|
|
2249
2256
|
/** Reset inactivity timeout in ms (default: 5 min) */
|
|
@@ -2306,6 +2313,23 @@ declare class BlinkSandboxImpl implements BlinkSandbox {
|
|
|
2306
2313
|
* Factory function and client class for the Blink SDK
|
|
2307
2314
|
*/
|
|
2308
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;
|
|
2309
2333
|
interface BlinkClient {
|
|
2310
2334
|
auth: BlinkAuth;
|
|
2311
2335
|
db: BlinkDatabase;
|
|
@@ -2320,8 +2344,39 @@ interface BlinkClient {
|
|
|
2320
2344
|
rag: BlinkRAG;
|
|
2321
2345
|
sandbox: BlinkSandbox;
|
|
2322
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
|
+
}
|
|
2323
2364
|
/**
|
|
2324
|
-
* 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
|
+
* ```
|
|
2325
2380
|
*/
|
|
2326
2381
|
declare function createClient(config: BlinkClientConfig): BlinkClient;
|
|
2327
2382
|
|
|
@@ -2620,6 +2675,8 @@ interface AgentResponse {
|
|
|
2620
2675
|
* - Create agent instance with config
|
|
2621
2676
|
* - Call agent.generate() for non-streaming
|
|
2622
2677
|
* - Call agent.stream() for streaming
|
|
2678
|
+
*
|
|
2679
|
+
* Auto-binds to default client when createClient() has been called.
|
|
2623
2680
|
*/
|
|
2624
2681
|
|
|
2625
2682
|
/**
|
|
@@ -2679,34 +2736,38 @@ interface StreamOptions {
|
|
|
2679
2736
|
* - `agent.generate({ prompt })` for non-streaming one-shot generation
|
|
2680
2737
|
* - `agent.stream({ prompt })` for streaming real-time generation
|
|
2681
2738
|
*
|
|
2739
|
+
* **Auto-binding:** After calling `createClient()`, agents automatically
|
|
2740
|
+
* bind to the default client. No need for `blink.ai.createAgent()`.
|
|
2741
|
+
*
|
|
2682
2742
|
* @example
|
|
2683
2743
|
* ```ts
|
|
2684
|
-
* import { Agent, webSearch
|
|
2744
|
+
* import { createClient, Agent, webSearch } from '@blinkdotnew/sdk'
|
|
2685
2745
|
*
|
|
2746
|
+
* // Initialize client once
|
|
2747
|
+
* createClient({ projectId: '...', secretKey: '...' })
|
|
2748
|
+
*
|
|
2749
|
+
* // Create agent - auto-binds to default client
|
|
2686
2750
|
* const weatherAgent = new Agent({
|
|
2687
2751
|
* model: 'anthropic/claude-sonnet-4-20250514',
|
|
2688
2752
|
* system: 'You are a helpful weather assistant.',
|
|
2689
|
-
* tools: [webSearch
|
|
2753
|
+
* tools: [webSearch],
|
|
2690
2754
|
* maxSteps: 10,
|
|
2691
2755
|
* })
|
|
2692
2756
|
*
|
|
2693
|
-
* //
|
|
2757
|
+
* // Works immediately - no binding needed!
|
|
2694
2758
|
* const result = await weatherAgent.generate({
|
|
2695
2759
|
* prompt: 'What is the weather in San Francisco?',
|
|
2696
2760
|
* })
|
|
2697
2761
|
* console.log(result.text)
|
|
2698
|
-
*
|
|
2699
|
-
* // Streaming
|
|
2700
|
-
* const stream = await weatherAgent.stream({
|
|
2701
|
-
* prompt: 'Tell me about weather patterns',
|
|
2702
|
-
* })
|
|
2703
2762
|
* ```
|
|
2704
2763
|
*/
|
|
2705
2764
|
declare class Agent {
|
|
2706
2765
|
private httpClient;
|
|
2707
2766
|
private readonly config;
|
|
2708
2767
|
/**
|
|
2709
|
-
* Create a new Agent instance
|
|
2768
|
+
* Create a new Agent instance.
|
|
2769
|
+
* Auto-binds to default client if createClient() was called.
|
|
2770
|
+
*
|
|
2710
2771
|
* @param options - Agent configuration options
|
|
2711
2772
|
*/
|
|
2712
2773
|
constructor(options: AgentOptions);
|
|
@@ -3661,4 +3722,4 @@ declare const mediaTools: readonly ["generate_image", "edit_image", "generate_vi
|
|
|
3661
3722
|
*/
|
|
3662
3723
|
declare function serializeTools(tools: string[]): string[];
|
|
3663
3724
|
|
|
3664
|
-
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
|
@@ -6454,7 +6454,9 @@ var Agent = class {
|
|
|
6454
6454
|
httpClient = null;
|
|
6455
6455
|
config;
|
|
6456
6456
|
/**
|
|
6457
|
-
* Create a new Agent instance
|
|
6457
|
+
* Create a new Agent instance.
|
|
6458
|
+
* Auto-binds to default client if createClient() was called.
|
|
6459
|
+
*
|
|
6458
6460
|
* @param options - Agent configuration options
|
|
6459
6461
|
*/
|
|
6460
6462
|
constructor(options) {
|
|
@@ -6462,6 +6464,10 @@ var Agent = class {
|
|
|
6462
6464
|
throw new BlinkAIError("Agent model is required");
|
|
6463
6465
|
}
|
|
6464
6466
|
this.config = options;
|
|
6467
|
+
try {
|
|
6468
|
+
this.httpClient = _getDefaultHttpClient();
|
|
6469
|
+
} catch {
|
|
6470
|
+
}
|
|
6465
6471
|
}
|
|
6466
6472
|
/**
|
|
6467
6473
|
* Internal: Set the HTTP client (called by BlinkClient)
|
|
@@ -6504,7 +6510,7 @@ var Agent = class {
|
|
|
6504
6510
|
async generate(options) {
|
|
6505
6511
|
if (!this.httpClient) {
|
|
6506
6512
|
throw new BlinkAIError(
|
|
6507
|
-
"Agent not initialized.
|
|
6513
|
+
"Agent not initialized. Call createClient() first, or use useAgent() in React."
|
|
6508
6514
|
);
|
|
6509
6515
|
}
|
|
6510
6516
|
if (!options.prompt && !options.messages) {
|
|
@@ -6561,7 +6567,7 @@ var Agent = class {
|
|
|
6561
6567
|
async stream(options) {
|
|
6562
6568
|
if (!this.httpClient) {
|
|
6563
6569
|
throw new BlinkAIError(
|
|
6564
|
-
"Agent not initialized.
|
|
6570
|
+
"Agent not initialized. Call createClient() first, or use useAgent() in React."
|
|
6565
6571
|
);
|
|
6566
6572
|
}
|
|
6567
6573
|
if (!options.prompt && !options.messages) {
|
|
@@ -9173,7 +9179,8 @@ var BlinkSandboxImpl = class {
|
|
|
9173
9179
|
const body = {
|
|
9174
9180
|
template: options.template,
|
|
9175
9181
|
timeout_ms: options.timeoutMs,
|
|
9176
|
-
metadata: options.metadata
|
|
9182
|
+
metadata: options.metadata,
|
|
9183
|
+
secrets: options.secrets
|
|
9177
9184
|
};
|
|
9178
9185
|
const response = await this.httpClient.post(this.url("/create"), body);
|
|
9179
9186
|
const { id, template, host_pattern } = response.data;
|
|
@@ -9211,6 +9218,18 @@ var BlinkSandboxImpl = class {
|
|
|
9211
9218
|
};
|
|
9212
9219
|
|
|
9213
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
|
+
}
|
|
9214
9233
|
var BlinkClientImpl = class {
|
|
9215
9234
|
auth;
|
|
9216
9235
|
db;
|
|
@@ -9224,32 +9243,33 @@ var BlinkClientImpl = class {
|
|
|
9224
9243
|
functions;
|
|
9225
9244
|
rag;
|
|
9226
9245
|
sandbox;
|
|
9227
|
-
|
|
9246
|
+
/** @internal HTTP client for Agent auto-binding */
|
|
9247
|
+
_httpClient;
|
|
9228
9248
|
constructor(config) {
|
|
9229
9249
|
if ((config.secretKey || config.serviceToken) && isBrowser) {
|
|
9230
9250
|
throw new Error("secretKey/serviceToken is server-only. Do not provide it in browser/React Native clients.");
|
|
9231
9251
|
}
|
|
9232
9252
|
this.auth = new BlinkAuth(config);
|
|
9233
|
-
this.
|
|
9253
|
+
this._httpClient = new HttpClient(
|
|
9234
9254
|
config,
|
|
9235
9255
|
() => this.auth.getToken(),
|
|
9236
9256
|
() => this.auth.getValidToken()
|
|
9237
9257
|
);
|
|
9238
|
-
this.db = new BlinkDatabase(this.
|
|
9239
|
-
this.storage = new BlinkStorageImpl(this.
|
|
9240
|
-
this.ai = new BlinkAIImpl(this.
|
|
9241
|
-
this.data = new BlinkDataImpl(this.
|
|
9242
|
-
this.realtime = new BlinkRealtimeImpl(this.
|
|
9243
|
-
this.notifications = new BlinkNotificationsImpl(this.
|
|
9244
|
-
this.analytics = new BlinkAnalyticsImpl(this.
|
|
9245
|
-
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);
|
|
9246
9266
|
this.functions = new BlinkFunctionsImpl(
|
|
9247
|
-
this.
|
|
9267
|
+
this._httpClient,
|
|
9248
9268
|
config.projectId,
|
|
9249
9269
|
() => this.auth.getValidToken()
|
|
9250
9270
|
);
|
|
9251
|
-
this.rag = new BlinkRAGImpl(this.
|
|
9252
|
-
this.sandbox = new BlinkSandboxImpl(this.
|
|
9271
|
+
this.rag = new BlinkRAGImpl(this._httpClient);
|
|
9272
|
+
this.sandbox = new BlinkSandboxImpl(this._httpClient);
|
|
9253
9273
|
this.auth.onAuthStateChanged((state) => {
|
|
9254
9274
|
if (state.isAuthenticated && state.user) {
|
|
9255
9275
|
this.analytics.setUserId(state.user.id);
|
|
@@ -9265,7 +9285,9 @@ function createClient(config) {
|
|
|
9265
9285
|
if (!config.projectId) {
|
|
9266
9286
|
throw new Error("projectId is required");
|
|
9267
9287
|
}
|
|
9268
|
-
|
|
9288
|
+
const client = new BlinkClientImpl(config);
|
|
9289
|
+
defaultClient = client;
|
|
9290
|
+
return client;
|
|
9269
9291
|
}
|
|
9270
9292
|
|
|
9271
9293
|
exports.Agent = Agent;
|
|
@@ -9297,6 +9319,7 @@ exports.editImage = editImage;
|
|
|
9297
9319
|
exports.fetchUrl = fetchUrl;
|
|
9298
9320
|
exports.generateImage = generateImage;
|
|
9299
9321
|
exports.generateVideo = generateVideo;
|
|
9322
|
+
exports.getDefaultClient = getDefaultClient;
|
|
9300
9323
|
exports.getDefaultStorageAdapter = getDefaultStorageAdapter;
|
|
9301
9324
|
exports.getHost = getHost;
|
|
9302
9325
|
exports.globFileSearch = globFileSearch;
|
package/dist/index.mjs
CHANGED
|
@@ -6452,7 +6452,9 @@ var Agent = class {
|
|
|
6452
6452
|
httpClient = null;
|
|
6453
6453
|
config;
|
|
6454
6454
|
/**
|
|
6455
|
-
* Create a new Agent instance
|
|
6455
|
+
* Create a new Agent instance.
|
|
6456
|
+
* Auto-binds to default client if createClient() was called.
|
|
6457
|
+
*
|
|
6456
6458
|
* @param options - Agent configuration options
|
|
6457
6459
|
*/
|
|
6458
6460
|
constructor(options) {
|
|
@@ -6460,6 +6462,10 @@ var Agent = class {
|
|
|
6460
6462
|
throw new BlinkAIError("Agent model is required");
|
|
6461
6463
|
}
|
|
6462
6464
|
this.config = options;
|
|
6465
|
+
try {
|
|
6466
|
+
this.httpClient = _getDefaultHttpClient();
|
|
6467
|
+
} catch {
|
|
6468
|
+
}
|
|
6463
6469
|
}
|
|
6464
6470
|
/**
|
|
6465
6471
|
* Internal: Set the HTTP client (called by BlinkClient)
|
|
@@ -6502,7 +6508,7 @@ var Agent = class {
|
|
|
6502
6508
|
async generate(options) {
|
|
6503
6509
|
if (!this.httpClient) {
|
|
6504
6510
|
throw new BlinkAIError(
|
|
6505
|
-
"Agent not initialized.
|
|
6511
|
+
"Agent not initialized. Call createClient() first, or use useAgent() in React."
|
|
6506
6512
|
);
|
|
6507
6513
|
}
|
|
6508
6514
|
if (!options.prompt && !options.messages) {
|
|
@@ -6559,7 +6565,7 @@ var Agent = class {
|
|
|
6559
6565
|
async stream(options) {
|
|
6560
6566
|
if (!this.httpClient) {
|
|
6561
6567
|
throw new BlinkAIError(
|
|
6562
|
-
"Agent not initialized.
|
|
6568
|
+
"Agent not initialized. Call createClient() first, or use useAgent() in React."
|
|
6563
6569
|
);
|
|
6564
6570
|
}
|
|
6565
6571
|
if (!options.prompt && !options.messages) {
|
|
@@ -9171,7 +9177,8 @@ var BlinkSandboxImpl = class {
|
|
|
9171
9177
|
const body = {
|
|
9172
9178
|
template: options.template,
|
|
9173
9179
|
timeout_ms: options.timeoutMs,
|
|
9174
|
-
metadata: options.metadata
|
|
9180
|
+
metadata: options.metadata,
|
|
9181
|
+
secrets: options.secrets
|
|
9175
9182
|
};
|
|
9176
9183
|
const response = await this.httpClient.post(this.url("/create"), body);
|
|
9177
9184
|
const { id, template, host_pattern } = response.data;
|
|
@@ -9209,6 +9216,18 @@ var BlinkSandboxImpl = class {
|
|
|
9209
9216
|
};
|
|
9210
9217
|
|
|
9211
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
|
+
}
|
|
9212
9231
|
var BlinkClientImpl = class {
|
|
9213
9232
|
auth;
|
|
9214
9233
|
db;
|
|
@@ -9222,32 +9241,33 @@ var BlinkClientImpl = class {
|
|
|
9222
9241
|
functions;
|
|
9223
9242
|
rag;
|
|
9224
9243
|
sandbox;
|
|
9225
|
-
|
|
9244
|
+
/** @internal HTTP client for Agent auto-binding */
|
|
9245
|
+
_httpClient;
|
|
9226
9246
|
constructor(config) {
|
|
9227
9247
|
if ((config.secretKey || config.serviceToken) && isBrowser) {
|
|
9228
9248
|
throw new Error("secretKey/serviceToken is server-only. Do not provide it in browser/React Native clients.");
|
|
9229
9249
|
}
|
|
9230
9250
|
this.auth = new BlinkAuth(config);
|
|
9231
|
-
this.
|
|
9251
|
+
this._httpClient = new HttpClient(
|
|
9232
9252
|
config,
|
|
9233
9253
|
() => this.auth.getToken(),
|
|
9234
9254
|
() => this.auth.getValidToken()
|
|
9235
9255
|
);
|
|
9236
|
-
this.db = new BlinkDatabase(this.
|
|
9237
|
-
this.storage = new BlinkStorageImpl(this.
|
|
9238
|
-
this.ai = new BlinkAIImpl(this.
|
|
9239
|
-
this.data = new BlinkDataImpl(this.
|
|
9240
|
-
this.realtime = new BlinkRealtimeImpl(this.
|
|
9241
|
-
this.notifications = new BlinkNotificationsImpl(this.
|
|
9242
|
-
this.analytics = new BlinkAnalyticsImpl(this.
|
|
9243
|
-
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);
|
|
9244
9264
|
this.functions = new BlinkFunctionsImpl(
|
|
9245
|
-
this.
|
|
9265
|
+
this._httpClient,
|
|
9246
9266
|
config.projectId,
|
|
9247
9267
|
() => this.auth.getValidToken()
|
|
9248
9268
|
);
|
|
9249
|
-
this.rag = new BlinkRAGImpl(this.
|
|
9250
|
-
this.sandbox = new BlinkSandboxImpl(this.
|
|
9269
|
+
this.rag = new BlinkRAGImpl(this._httpClient);
|
|
9270
|
+
this.sandbox = new BlinkSandboxImpl(this._httpClient);
|
|
9251
9271
|
this.auth.onAuthStateChanged((state) => {
|
|
9252
9272
|
if (state.isAuthenticated && state.user) {
|
|
9253
9273
|
this.analytics.setUserId(state.user.id);
|
|
@@ -9263,9 +9283,11 @@ function createClient(config) {
|
|
|
9263
9283
|
if (!config.projectId) {
|
|
9264
9284
|
throw new Error("projectId is required");
|
|
9265
9285
|
}
|
|
9266
|
-
|
|
9286
|
+
const client = new BlinkClientImpl(config);
|
|
9287
|
+
defaultClient = client;
|
|
9288
|
+
return client;
|
|
9267
9289
|
}
|
|
9268
9290
|
|
|
9269
|
-
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 };
|
|
9270
9292
|
//# sourceMappingURL=index.mjs.map
|
|
9271
9293
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blinkdotnew/sdk",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.4",
|
|
4
4
|
"description": "Blink TypeScript SDK for client-side applications - Zero-boilerplate CRUD + auth + AI + analytics + notifications for modern SaaS/AI apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"blink",
|
|
@@ -51,8 +51,10 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {},
|
|
53
53
|
"devDependencies": {
|
|
54
|
+
"@blink/core": "0.4.1",
|
|
54
55
|
"tsup": "^8.0.0",
|
|
55
|
-
"typescript": "^5.0.0"
|
|
56
|
+
"typescript": "^5.0.0",
|
|
57
|
+
"@blinkdotnew/dev-sdk": "workspace:*"
|
|
56
58
|
},
|
|
57
59
|
"peerDependencies": {},
|
|
58
60
|
"publishConfig": {
|