@omnikit-ai/sdk 2.2.2 → 2.2.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 CHANGED
@@ -10,7 +10,7 @@ export { cleanTokenFromUrl, getAccessToken, isTokenInUrl, removeAccessToken, sav
10
10
  * SECURITY: getAccessToken requires service token authentication.
11
11
  * Only available to backend functions, not frontend code.
12
12
  */
13
- type ConnectorType = 'slack' | 'google_calendar' | 'gmail' | 'notion' | 'salesforce';
13
+ type ConnectorType = 'slack' | 'google_calendar' | 'gmail' | 'google_sheets' | 'notion' | 'salesforce';
14
14
  interface ConnectorAccessTokenResponse {
15
15
  success: boolean;
16
16
  access_token: string;
@@ -320,13 +320,28 @@ interface EmailParams {
320
320
  from_name?: string;
321
321
  }
322
322
  interface LLMMessage {
323
- role: 'system' | 'user' | 'assistant';
323
+ role: 'system' | 'user' | 'assistant' | 'tool';
324
324
  content: string | Array<{
325
325
  type: string;
326
326
  text?: string;
327
327
  file?: any;
328
328
  image_url?: any;
329
329
  }>;
330
+ /**
331
+ * For role="tool" messages - links to the tool_calls[].id from the assistant message.
332
+ * Required when role is "tool".
333
+ */
334
+ tool_call_id?: string;
335
+ /**
336
+ * For role="tool" messages - the function name that was called.
337
+ * Optional but recommended for clarity.
338
+ */
339
+ name?: string;
340
+ /**
341
+ * For assistant messages - tool calls the assistant wants to make.
342
+ * Present when the assistant decides to use tools.
343
+ */
344
+ tool_calls?: ToolCall[];
330
345
  }
331
346
  /**
332
347
  * Available LLM models:
@@ -1368,19 +1383,20 @@ interface OmnikitClient {
1368
1383
  /**
1369
1384
  * Get a secret value at runtime (for backend functions).
1370
1385
  *
1371
- * This method securely fetches secrets from the Omnikit API using the app's API key.
1372
- * Use this in Supabase Edge Functions instead of storing secrets in Supabase's
1373
- * environment variables to ensure proper isolation between apps.
1386
+ * This method securely fetches secrets from the Omnikit API at runtime.
1387
+ * Secrets are NOT injected into function code - they are fetched via API
1388
+ * to ensure they cannot be leaked through source code, logs, or backups.
1374
1389
  *
1375
1390
  * @example
1376
1391
  * ```typescript
1392
+ * const omnikit = createServerClient(req);
1377
1393
  * const stripeKey = await omnikit.getSecret('STRIPE_SECRET_KEY');
1378
1394
  * const stripe = new Stripe(stripeKey);
1379
1395
  * ```
1380
1396
  *
1381
1397
  * @param secretName - Name of the secret to retrieve
1382
1398
  * @returns The decrypted secret value
1383
- * @throws Error if the secret is not found or API key is invalid
1399
+ * @throws Error if the secret is not found or service token is invalid
1384
1400
  */
1385
1401
  getSecret(secretName: string): Promise<string>;
1386
1402
  }
@@ -2143,26 +2159,29 @@ declare class APIClient implements OmnikitClient {
2143
2159
  /**
2144
2160
  * Get a secret value at runtime (for backend functions).
2145
2161
  *
2146
- * This method securely fetches secrets from the Omnikit API using the app's API key.
2147
- * Use this in Supabase Edge Functions instead of storing secrets in Supabase's
2148
- * environment variables to ensure proper isolation between apps.
2162
+ * This method securely fetches secrets from the Omnikit API at runtime.
2163
+ * Secrets are NOT injected into function code - they are fetched via API
2164
+ * to ensure they cannot be leaked through source code, logs, or backups.
2149
2165
  *
2150
2166
  * @example
2151
2167
  * ```typescript
2152
2168
  * // In a backend function (Deno Edge Function)
2153
- * const omnikit = createClient({
2154
- * appId: __OMNIKIT_APP_ID__,
2155
- * serverUrl: __OMNIKIT_API_URL__,
2156
- * apiKey: __OMNIKIT_API_KEY__,
2157
- * });
2169
+ * import { createServerClient } from '@omnikit-ai/sdk';
2158
2170
  *
2159
- * const stripeKey = await omnikit.getSecret('STRIPE_SECRET_KEY');
2160
- * const stripe = new Stripe(stripeKey);
2171
+ * Deno.serve(async (req) => {
2172
+ * const omnikit = createServerClient(req);
2173
+ *
2174
+ * // Fetch secret at runtime - secure, never in source code
2175
+ * const stripeKey = await omnikit.getSecret('STRIPE_SECRET_KEY');
2176
+ * const stripe = new Stripe(stripeKey);
2177
+ *
2178
+ * // ... rest of function
2179
+ * });
2161
2180
  * ```
2162
2181
  *
2163
2182
  * @param secretName - Name of the secret to retrieve
2164
2183
  * @returns The decrypted secret value
2165
- * @throws Error if the secret is not found or API key is invalid
2184
+ * @throws Error if the secret is not found or service token is invalid
2166
2185
  */
2167
2186
  getSecret(secretName: string): Promise<string>;
2168
2187
  }
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export { cleanTokenFromUrl, getAccessToken, isTokenInUrl, removeAccessToken, sav
10
10
  * SECURITY: getAccessToken requires service token authentication.
11
11
  * Only available to backend functions, not frontend code.
12
12
  */
13
- type ConnectorType = 'slack' | 'google_calendar' | 'gmail' | 'notion' | 'salesforce';
13
+ type ConnectorType = 'slack' | 'google_calendar' | 'gmail' | 'google_sheets' | 'notion' | 'salesforce';
14
14
  interface ConnectorAccessTokenResponse {
15
15
  success: boolean;
16
16
  access_token: string;
@@ -320,13 +320,28 @@ interface EmailParams {
320
320
  from_name?: string;
321
321
  }
322
322
  interface LLMMessage {
323
- role: 'system' | 'user' | 'assistant';
323
+ role: 'system' | 'user' | 'assistant' | 'tool';
324
324
  content: string | Array<{
325
325
  type: string;
326
326
  text?: string;
327
327
  file?: any;
328
328
  image_url?: any;
329
329
  }>;
330
+ /**
331
+ * For role="tool" messages - links to the tool_calls[].id from the assistant message.
332
+ * Required when role is "tool".
333
+ */
334
+ tool_call_id?: string;
335
+ /**
336
+ * For role="tool" messages - the function name that was called.
337
+ * Optional but recommended for clarity.
338
+ */
339
+ name?: string;
340
+ /**
341
+ * For assistant messages - tool calls the assistant wants to make.
342
+ * Present when the assistant decides to use tools.
343
+ */
344
+ tool_calls?: ToolCall[];
330
345
  }
331
346
  /**
332
347
  * Available LLM models:
@@ -1368,19 +1383,20 @@ interface OmnikitClient {
1368
1383
  /**
1369
1384
  * Get a secret value at runtime (for backend functions).
1370
1385
  *
1371
- * This method securely fetches secrets from the Omnikit API using the app's API key.
1372
- * Use this in Supabase Edge Functions instead of storing secrets in Supabase's
1373
- * environment variables to ensure proper isolation between apps.
1386
+ * This method securely fetches secrets from the Omnikit API at runtime.
1387
+ * Secrets are NOT injected into function code - they are fetched via API
1388
+ * to ensure they cannot be leaked through source code, logs, or backups.
1374
1389
  *
1375
1390
  * @example
1376
1391
  * ```typescript
1392
+ * const omnikit = createServerClient(req);
1377
1393
  * const stripeKey = await omnikit.getSecret('STRIPE_SECRET_KEY');
1378
1394
  * const stripe = new Stripe(stripeKey);
1379
1395
  * ```
1380
1396
  *
1381
1397
  * @param secretName - Name of the secret to retrieve
1382
1398
  * @returns The decrypted secret value
1383
- * @throws Error if the secret is not found or API key is invalid
1399
+ * @throws Error if the secret is not found or service token is invalid
1384
1400
  */
1385
1401
  getSecret(secretName: string): Promise<string>;
1386
1402
  }
@@ -2143,26 +2159,29 @@ declare class APIClient implements OmnikitClient {
2143
2159
  /**
2144
2160
  * Get a secret value at runtime (for backend functions).
2145
2161
  *
2146
- * This method securely fetches secrets from the Omnikit API using the app's API key.
2147
- * Use this in Supabase Edge Functions instead of storing secrets in Supabase's
2148
- * environment variables to ensure proper isolation between apps.
2162
+ * This method securely fetches secrets from the Omnikit API at runtime.
2163
+ * Secrets are NOT injected into function code - they are fetched via API
2164
+ * to ensure they cannot be leaked through source code, logs, or backups.
2149
2165
  *
2150
2166
  * @example
2151
2167
  * ```typescript
2152
2168
  * // In a backend function (Deno Edge Function)
2153
- * const omnikit = createClient({
2154
- * appId: __OMNIKIT_APP_ID__,
2155
- * serverUrl: __OMNIKIT_API_URL__,
2156
- * apiKey: __OMNIKIT_API_KEY__,
2157
- * });
2169
+ * import { createServerClient } from '@omnikit-ai/sdk';
2158
2170
  *
2159
- * const stripeKey = await omnikit.getSecret('STRIPE_SECRET_KEY');
2160
- * const stripe = new Stripe(stripeKey);
2171
+ * Deno.serve(async (req) => {
2172
+ * const omnikit = createServerClient(req);
2173
+ *
2174
+ * // Fetch secret at runtime - secure, never in source code
2175
+ * const stripeKey = await omnikit.getSecret('STRIPE_SECRET_KEY');
2176
+ * const stripe = new Stripe(stripeKey);
2177
+ *
2178
+ * // ... rest of function
2179
+ * });
2161
2180
  * ```
2162
2181
  *
2163
2182
  * @param secretName - Name of the secret to retrieve
2164
2183
  * @returns The decrypted secret value
2165
- * @throws Error if the secret is not found or API key is invalid
2184
+ * @throws Error if the secret is not found or service token is invalid
2166
2185
  */
2167
2186
  getSecret(secretName: string): Promise<string>;
2168
2187
  }
package/dist/index.js CHANGED
@@ -1721,7 +1721,7 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
1721
1721
  if (options.offset !== void 0) {
1722
1722
  queryParams.append("offset", String(options.offset));
1723
1723
  }
1724
- if (options.after !== void 0) {
1724
+ if (options.after) {
1725
1725
  queryParams.append("after", options.after);
1726
1726
  }
1727
1727
  }
@@ -2689,43 +2689,52 @@ Example: await ${collectionName}.list({ limit: 100, sort: '-created_at' })`,
2689
2689
  /**
2690
2690
  * Get a secret value at runtime (for backend functions).
2691
2691
  *
2692
- * This method securely fetches secrets from the Omnikit API using the app's API key.
2693
- * Use this in Supabase Edge Functions instead of storing secrets in Supabase's
2694
- * environment variables to ensure proper isolation between apps.
2692
+ * This method securely fetches secrets from the Omnikit API at runtime.
2693
+ * Secrets are NOT injected into function code - they are fetched via API
2694
+ * to ensure they cannot be leaked through source code, logs, or backups.
2695
2695
  *
2696
2696
  * @example
2697
2697
  * ```typescript
2698
2698
  * // In a backend function (Deno Edge Function)
2699
- * const omnikit = createClient({
2700
- * appId: __OMNIKIT_APP_ID__,
2701
- * serverUrl: __OMNIKIT_API_URL__,
2702
- * apiKey: __OMNIKIT_API_KEY__,
2703
- * });
2699
+ * import { createServerClient } from '@omnikit-ai/sdk';
2700
+ *
2701
+ * Deno.serve(async (req) => {
2702
+ * const omnikit = createServerClient(req);
2703
+ *
2704
+ * // Fetch secret at runtime - secure, never in source code
2705
+ * const stripeKey = await omnikit.getSecret('STRIPE_SECRET_KEY');
2706
+ * const stripe = new Stripe(stripeKey);
2704
2707
  *
2705
- * const stripeKey = await omnikit.getSecret('STRIPE_SECRET_KEY');
2706
- * const stripe = new Stripe(stripeKey);
2708
+ * // ... rest of function
2709
+ * });
2707
2710
  * ```
2708
2711
  *
2709
2712
  * @param secretName - Name of the secret to retrieve
2710
2713
  * @returns The decrypted secret value
2711
- * @throws Error if the secret is not found or API key is invalid
2714
+ * @throws Error if the secret is not found or service token is invalid
2712
2715
  */
2713
2716
  async getSecret(secretName) {
2714
- if (!this._apiKey) {
2717
+ const authToken = this._serviceToken || this._apiKey;
2718
+ if (!authToken) {
2715
2719
  throw new OmnikitError(
2716
- "API key is required to fetch secrets. Provide apiKey in config.",
2720
+ "Service token required. Use createServerClient(req) in backend functions.",
2717
2721
  403,
2718
- "API_KEY_REQUIRED"
2722
+ "AUTH_REQUIRED"
2719
2723
  );
2720
2724
  }
2725
+ const headers = {
2726
+ "Content-Type": "application/json"
2727
+ };
2728
+ if (this._serviceToken) {
2729
+ headers["X-Service-Token"] = this._serviceToken;
2730
+ } else if (this._apiKey) {
2731
+ headers["X-API-Key"] = this._apiKey;
2732
+ }
2721
2733
  const response = await fetch(
2722
2734
  `${this.baseUrl}/apps/${this.appId}/secrets/${secretName}/value`,
2723
2735
  {
2724
2736
  method: "GET",
2725
- headers: {
2726
- "X-API-Key": this._apiKey,
2727
- "Content-Type": "application/json"
2728
- }
2737
+ headers
2729
2738
  }
2730
2739
  );
2731
2740
  if (!response.ok) {