@blinkdotnew/dev-sdk 2.3.0 → 2.3.1

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 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, fetchUrl } from '@blinkdotnew/sdk'
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, fetchUrl],
2753
+ * tools: [webSearch],
2690
2754
  * maxSteps: 10,
2691
2755
  * })
2692
2756
  *
2693
- * // Non-streaming
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, fetchUrl } from '@blinkdotnew/sdk'
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, fetchUrl],
2753
+ * tools: [webSearch],
2690
2754
  * maxSteps: 10,
2691
2755
  * })
2692
2756
  *
2693
- * // Non-streaming
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
@@ -4576,25 +4576,17 @@ var BlinkAuth = class {
4576
4576
  }
4577
4577
  const { sessionId, authUrl } = await this.initiateMobileOAuth(provider, options);
4578
4578
  console.log("\u{1F510} Opening OAuth browser for", provider);
4579
- const result = await webBrowser.openAuthSessionAsync(authUrl);
4580
- console.log("\u{1F510} Browser closed with result:", result.type);
4581
- try {
4582
- const user = await this.pollMobileOAuthSession(sessionId, {
4583
- maxAttempts: 60,
4584
- // 30 seconds (500ms intervals)
4585
- intervalMs: 500
4586
- });
4587
- console.log("\u2705 OAuth completed successfully");
4588
- return user;
4589
- } catch (pollError) {
4590
- if (result.type === "cancel" || result.type === "dismiss") {
4591
- throw new BlinkAuthError(
4592
- "POPUP_CANCELED" /* POPUP_CANCELED */,
4593
- "Authentication was canceled"
4594
- );
4595
- }
4596
- throw pollError;
4597
- }
4579
+ webBrowser.openAuthSessionAsync(authUrl).then((result) => {
4580
+ console.log("\u{1F510} Browser closed with result:", result.type);
4581
+ }).catch(() => {
4582
+ });
4583
+ const user = await this.pollMobileOAuthSession(sessionId, {
4584
+ maxAttempts: 120,
4585
+ // 60 seconds (give user time to complete auth)
4586
+ intervalMs: 500
4587
+ });
4588
+ console.log("\u2705 OAuth completed successfully");
4589
+ return user;
4598
4590
  }
4599
4591
  /**
4600
4592
  * Generic provider sign-in method (headless mode)
@@ -6454,7 +6446,9 @@ var Agent = class {
6454
6446
  httpClient = null;
6455
6447
  config;
6456
6448
  /**
6457
- * Create a new Agent instance
6449
+ * Create a new Agent instance.
6450
+ * Auto-binds to default client if createClient() was called.
6451
+ *
6458
6452
  * @param options - Agent configuration options
6459
6453
  */
6460
6454
  constructor(options) {
@@ -6462,6 +6456,10 @@ var Agent = class {
6462
6456
  throw new BlinkAIError("Agent model is required");
6463
6457
  }
6464
6458
  this.config = options;
6459
+ try {
6460
+ this.httpClient = _getDefaultHttpClient();
6461
+ } catch {
6462
+ }
6465
6463
  }
6466
6464
  /**
6467
6465
  * Internal: Set the HTTP client (called by BlinkClient)
@@ -6504,7 +6502,7 @@ var Agent = class {
6504
6502
  async generate(options) {
6505
6503
  if (!this.httpClient) {
6506
6504
  throw new BlinkAIError(
6507
- "Agent not initialized. Use blink.ai.createAgent() or pass the agent to useAgent()."
6505
+ "Agent not initialized. Call createClient() first, or use useAgent() in React."
6508
6506
  );
6509
6507
  }
6510
6508
  if (!options.prompt && !options.messages) {
@@ -6561,7 +6559,7 @@ var Agent = class {
6561
6559
  async stream(options) {
6562
6560
  if (!this.httpClient) {
6563
6561
  throw new BlinkAIError(
6564
- "Agent not initialized. Use blink.ai.createAgent() or pass the agent to useAgent()."
6562
+ "Agent not initialized. Call createClient() first, or use useAgent() in React."
6565
6563
  );
6566
6564
  }
6567
6565
  if (!options.prompt && !options.messages) {
@@ -9173,7 +9171,8 @@ var BlinkSandboxImpl = class {
9173
9171
  const body = {
9174
9172
  template: options.template,
9175
9173
  timeout_ms: options.timeoutMs,
9176
- metadata: options.metadata
9174
+ metadata: options.metadata,
9175
+ secrets: options.secrets
9177
9176
  };
9178
9177
  const response = await this.httpClient.post(this.url("/create"), body);
9179
9178
  const { id, template, host_pattern } = response.data;
@@ -9211,6 +9210,18 @@ var BlinkSandboxImpl = class {
9211
9210
  };
9212
9211
 
9213
9212
  // src/client.ts
9213
+ var defaultClient = null;
9214
+ function getDefaultClient() {
9215
+ if (!defaultClient) {
9216
+ throw new Error(
9217
+ "No Blink client initialized. Call createClient() first before using Agent or other SDK features."
9218
+ );
9219
+ }
9220
+ return defaultClient;
9221
+ }
9222
+ function _getDefaultHttpClient() {
9223
+ return getDefaultClient()._httpClient;
9224
+ }
9214
9225
  var BlinkClientImpl = class {
9215
9226
  auth;
9216
9227
  db;
@@ -9224,32 +9235,33 @@ var BlinkClientImpl = class {
9224
9235
  functions;
9225
9236
  rag;
9226
9237
  sandbox;
9227
- httpClient;
9238
+ /** @internal HTTP client for Agent auto-binding */
9239
+ _httpClient;
9228
9240
  constructor(config) {
9229
9241
  if ((config.secretKey || config.serviceToken) && isBrowser) {
9230
9242
  throw new Error("secretKey/serviceToken is server-only. Do not provide it in browser/React Native clients.");
9231
9243
  }
9232
9244
  this.auth = new BlinkAuth(config);
9233
- this.httpClient = new HttpClient(
9245
+ this._httpClient = new HttpClient(
9234
9246
  config,
9235
9247
  () => this.auth.getToken(),
9236
9248
  () => this.auth.getValidToken()
9237
9249
  );
9238
- this.db = new BlinkDatabase(this.httpClient);
9239
- this.storage = new BlinkStorageImpl(this.httpClient);
9240
- this.ai = new BlinkAIImpl(this.httpClient);
9241
- this.data = new BlinkDataImpl(this.httpClient, config.projectId);
9242
- this.realtime = new BlinkRealtimeImpl(this.httpClient, config.projectId);
9243
- this.notifications = new BlinkNotificationsImpl(this.httpClient);
9244
- this.analytics = new BlinkAnalyticsImpl(this.httpClient, config.projectId);
9245
- this.connectors = new BlinkConnectorsImpl(this.httpClient);
9250
+ this.db = new BlinkDatabase(this._httpClient);
9251
+ this.storage = new BlinkStorageImpl(this._httpClient);
9252
+ this.ai = new BlinkAIImpl(this._httpClient);
9253
+ this.data = new BlinkDataImpl(this._httpClient, config.projectId);
9254
+ this.realtime = new BlinkRealtimeImpl(this._httpClient, config.projectId);
9255
+ this.notifications = new BlinkNotificationsImpl(this._httpClient);
9256
+ this.analytics = new BlinkAnalyticsImpl(this._httpClient, config.projectId);
9257
+ this.connectors = new BlinkConnectorsImpl(this._httpClient);
9246
9258
  this.functions = new BlinkFunctionsImpl(
9247
- this.httpClient,
9259
+ this._httpClient,
9248
9260
  config.projectId,
9249
9261
  () => this.auth.getValidToken()
9250
9262
  );
9251
- this.rag = new BlinkRAGImpl(this.httpClient);
9252
- this.sandbox = new BlinkSandboxImpl(this.httpClient);
9263
+ this.rag = new BlinkRAGImpl(this._httpClient);
9264
+ this.sandbox = new BlinkSandboxImpl(this._httpClient);
9253
9265
  this.auth.onAuthStateChanged((state) => {
9254
9266
  if (state.isAuthenticated && state.user) {
9255
9267
  this.analytics.setUserId(state.user.id);
@@ -9265,7 +9277,9 @@ function createClient(config) {
9265
9277
  if (!config.projectId) {
9266
9278
  throw new Error("projectId is required");
9267
9279
  }
9268
- return new BlinkClientImpl(config);
9280
+ const client = new BlinkClientImpl(config);
9281
+ defaultClient = client;
9282
+ return client;
9269
9283
  }
9270
9284
 
9271
9285
  exports.Agent = Agent;
@@ -9297,6 +9311,7 @@ exports.editImage = editImage;
9297
9311
  exports.fetchUrl = fetchUrl;
9298
9312
  exports.generateImage = generateImage;
9299
9313
  exports.generateVideo = generateVideo;
9314
+ exports.getDefaultClient = getDefaultClient;
9300
9315
  exports.getDefaultStorageAdapter = getDefaultStorageAdapter;
9301
9316
  exports.getHost = getHost;
9302
9317
  exports.globFileSearch = globFileSearch;
package/dist/index.mjs CHANGED
@@ -4574,25 +4574,17 @@ var BlinkAuth = class {
4574
4574
  }
4575
4575
  const { sessionId, authUrl } = await this.initiateMobileOAuth(provider, options);
4576
4576
  console.log("\u{1F510} Opening OAuth browser for", provider);
4577
- const result = await webBrowser.openAuthSessionAsync(authUrl);
4578
- console.log("\u{1F510} Browser closed with result:", result.type);
4579
- try {
4580
- const user = await this.pollMobileOAuthSession(sessionId, {
4581
- maxAttempts: 60,
4582
- // 30 seconds (500ms intervals)
4583
- intervalMs: 500
4584
- });
4585
- console.log("\u2705 OAuth completed successfully");
4586
- return user;
4587
- } catch (pollError) {
4588
- if (result.type === "cancel" || result.type === "dismiss") {
4589
- throw new BlinkAuthError(
4590
- "POPUP_CANCELED" /* POPUP_CANCELED */,
4591
- "Authentication was canceled"
4592
- );
4593
- }
4594
- throw pollError;
4595
- }
4577
+ webBrowser.openAuthSessionAsync(authUrl).then((result) => {
4578
+ console.log("\u{1F510} Browser closed with result:", result.type);
4579
+ }).catch(() => {
4580
+ });
4581
+ const user = await this.pollMobileOAuthSession(sessionId, {
4582
+ maxAttempts: 120,
4583
+ // 60 seconds (give user time to complete auth)
4584
+ intervalMs: 500
4585
+ });
4586
+ console.log("\u2705 OAuth completed successfully");
4587
+ return user;
4596
4588
  }
4597
4589
  /**
4598
4590
  * Generic provider sign-in method (headless mode)
@@ -6452,7 +6444,9 @@ var Agent = class {
6452
6444
  httpClient = null;
6453
6445
  config;
6454
6446
  /**
6455
- * Create a new Agent instance
6447
+ * Create a new Agent instance.
6448
+ * Auto-binds to default client if createClient() was called.
6449
+ *
6456
6450
  * @param options - Agent configuration options
6457
6451
  */
6458
6452
  constructor(options) {
@@ -6460,6 +6454,10 @@ var Agent = class {
6460
6454
  throw new BlinkAIError("Agent model is required");
6461
6455
  }
6462
6456
  this.config = options;
6457
+ try {
6458
+ this.httpClient = _getDefaultHttpClient();
6459
+ } catch {
6460
+ }
6463
6461
  }
6464
6462
  /**
6465
6463
  * Internal: Set the HTTP client (called by BlinkClient)
@@ -6502,7 +6500,7 @@ var Agent = class {
6502
6500
  async generate(options) {
6503
6501
  if (!this.httpClient) {
6504
6502
  throw new BlinkAIError(
6505
- "Agent not initialized. Use blink.ai.createAgent() or pass the agent to useAgent()."
6503
+ "Agent not initialized. Call createClient() first, or use useAgent() in React."
6506
6504
  );
6507
6505
  }
6508
6506
  if (!options.prompt && !options.messages) {
@@ -6559,7 +6557,7 @@ var Agent = class {
6559
6557
  async stream(options) {
6560
6558
  if (!this.httpClient) {
6561
6559
  throw new BlinkAIError(
6562
- "Agent not initialized. Use blink.ai.createAgent() or pass the agent to useAgent()."
6560
+ "Agent not initialized. Call createClient() first, or use useAgent() in React."
6563
6561
  );
6564
6562
  }
6565
6563
  if (!options.prompt && !options.messages) {
@@ -9171,7 +9169,8 @@ var BlinkSandboxImpl = class {
9171
9169
  const body = {
9172
9170
  template: options.template,
9173
9171
  timeout_ms: options.timeoutMs,
9174
- metadata: options.metadata
9172
+ metadata: options.metadata,
9173
+ secrets: options.secrets
9175
9174
  };
9176
9175
  const response = await this.httpClient.post(this.url("/create"), body);
9177
9176
  const { id, template, host_pattern } = response.data;
@@ -9209,6 +9208,18 @@ var BlinkSandboxImpl = class {
9209
9208
  };
9210
9209
 
9211
9210
  // src/client.ts
9211
+ var defaultClient = null;
9212
+ function getDefaultClient() {
9213
+ if (!defaultClient) {
9214
+ throw new Error(
9215
+ "No Blink client initialized. Call createClient() first before using Agent or other SDK features."
9216
+ );
9217
+ }
9218
+ return defaultClient;
9219
+ }
9220
+ function _getDefaultHttpClient() {
9221
+ return getDefaultClient()._httpClient;
9222
+ }
9212
9223
  var BlinkClientImpl = class {
9213
9224
  auth;
9214
9225
  db;
@@ -9222,32 +9233,33 @@ var BlinkClientImpl = class {
9222
9233
  functions;
9223
9234
  rag;
9224
9235
  sandbox;
9225
- httpClient;
9236
+ /** @internal HTTP client for Agent auto-binding */
9237
+ _httpClient;
9226
9238
  constructor(config) {
9227
9239
  if ((config.secretKey || config.serviceToken) && isBrowser) {
9228
9240
  throw new Error("secretKey/serviceToken is server-only. Do not provide it in browser/React Native clients.");
9229
9241
  }
9230
9242
  this.auth = new BlinkAuth(config);
9231
- this.httpClient = new HttpClient(
9243
+ this._httpClient = new HttpClient(
9232
9244
  config,
9233
9245
  () => this.auth.getToken(),
9234
9246
  () => this.auth.getValidToken()
9235
9247
  );
9236
- this.db = new BlinkDatabase(this.httpClient);
9237
- this.storage = new BlinkStorageImpl(this.httpClient);
9238
- this.ai = new BlinkAIImpl(this.httpClient);
9239
- this.data = new BlinkDataImpl(this.httpClient, config.projectId);
9240
- this.realtime = new BlinkRealtimeImpl(this.httpClient, config.projectId);
9241
- this.notifications = new BlinkNotificationsImpl(this.httpClient);
9242
- this.analytics = new BlinkAnalyticsImpl(this.httpClient, config.projectId);
9243
- this.connectors = new BlinkConnectorsImpl(this.httpClient);
9248
+ this.db = new BlinkDatabase(this._httpClient);
9249
+ this.storage = new BlinkStorageImpl(this._httpClient);
9250
+ this.ai = new BlinkAIImpl(this._httpClient);
9251
+ this.data = new BlinkDataImpl(this._httpClient, config.projectId);
9252
+ this.realtime = new BlinkRealtimeImpl(this._httpClient, config.projectId);
9253
+ this.notifications = new BlinkNotificationsImpl(this._httpClient);
9254
+ this.analytics = new BlinkAnalyticsImpl(this._httpClient, config.projectId);
9255
+ this.connectors = new BlinkConnectorsImpl(this._httpClient);
9244
9256
  this.functions = new BlinkFunctionsImpl(
9245
- this.httpClient,
9257
+ this._httpClient,
9246
9258
  config.projectId,
9247
9259
  () => this.auth.getValidToken()
9248
9260
  );
9249
- this.rag = new BlinkRAGImpl(this.httpClient);
9250
- this.sandbox = new BlinkSandboxImpl(this.httpClient);
9261
+ this.rag = new BlinkRAGImpl(this._httpClient);
9262
+ this.sandbox = new BlinkSandboxImpl(this._httpClient);
9251
9263
  this.auth.onAuthStateChanged((state) => {
9252
9264
  if (state.isAuthenticated && state.user) {
9253
9265
  this.analytics.setUserId(state.user.id);
@@ -9263,9 +9275,11 @@ function createClient(config) {
9263
9275
  if (!config.projectId) {
9264
9276
  throw new Error("projectId is required");
9265
9277
  }
9266
- return new BlinkClientImpl(config);
9278
+ const client = new BlinkClientImpl(config);
9279
+ defaultClient = client;
9280
+ return client;
9267
9281
  }
9268
9282
 
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 };
9283
+ 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
9284
  //# sourceMappingURL=index.mjs.map
9271
9285
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkdotnew/dev-sdk",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
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": {