@squidcloud/client 1.0.125 → 1.0.127

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.
@@ -16,4 +16,6 @@ export interface AiAssistantFileContext {
16
16
  export type AiAssistantContext = AiAssistantTextContext | AiAssistantUrlContext | AiAssistantFileContext;
17
17
  export interface AiAssistantChatOptions {
18
18
  maxTokens?: number;
19
+ chatId?: string;
20
+ disableHistory?: boolean;
19
21
  }
@@ -1,12 +1,8 @@
1
- /**
2
- * The appId is the unique identifier of an application.
3
- * It is the combination of the application id (as shown in the console), environment id (dev, prod) and the
4
- * developer id (if exists). For example - "fdgfd90ds-dev-1234567890abcdef"
5
- */
6
1
  /** A type alias for an application id. */
7
2
  export type AppId = string;
8
3
  export type EnvironmentId = 'prod' | 'dev';
9
4
  export declare const allEnvironmentIds: Array<EnvironmentId>;
10
5
  /** A type alias for an integration id. */
11
6
  export type IntegrationId = string;
7
+ export type ChatId = string;
12
8
  export type SquidDeveloperId = string;
@@ -43,7 +43,6 @@ export * from './utils/error';
43
43
  export * from './utils/http';
44
44
  export * from './utils/id';
45
45
  export * from './utils/lock.manager';
46
- export * from './utils/nullish';
47
46
  export * from './utils/object';
48
47
  export * from './utils/serialization';
49
48
  export * from './utils/transforms';
@@ -1,8 +1,3 @@
1
- /**
2
- * This file contains general validators for the different objects being received from the client. The parameters are
3
- * usually of type 'any' to make sure there are no assumptions that the object has the correct type.
4
- * Also, this file should avoid importing from other files that are not for validation to avoid circular deps.
5
- */
6
1
  import { OpenIdProvider } from '../application.types';
7
2
  import { HttpStatus } from '../http-status.enum';
8
3
  export type StatusCode = HttpStatus.BAD_REQUEST | HttpStatus.NOT_FOUND | HttpStatus.FORBIDDEN | HttpStatus.UNAUTHORIZED | HttpStatus.CONFLICT;
@@ -1,4 +1,4 @@
1
- import { AiAssistantContext, IntegrationId, AiModelName, AiAssistantChatOptions } from '@squidcloud/common';
1
+ import { AiAssistantChatOptions, AiAssistantContext, AiModelName, IntegrationId } from '@squidcloud/common';
2
2
  import { Observable } from 'rxjs';
3
3
  import { RpcManager } from './rpc.manager';
4
4
  import { SocketManager } from './socket.manager';
@@ -29,7 +29,7 @@ export declare class AiAssistantClient {
29
29
  chat(profileId: string, prompt: string, options?: AiAssistantChatOptions): Observable<string>;
30
30
  private handleChatResponse;
31
31
  }
32
- declare class AiAssistantProfileReference {
32
+ export declare class AiAssistantProfileReference {
33
33
  private readonly client;
34
34
  private readonly integrationId;
35
35
  private readonly profileId;
@@ -38,10 +38,11 @@ declare class AiAssistantProfileReference {
38
38
  * Sends a prompt to the current profile.
39
39
  *
40
40
  * @param prompt - The prompt.
41
+ * @param options - The chat options.
41
42
  * @returns An observable that emits when a new response token is received. The emitted value is the entire response
42
43
  * that has been received so far.
43
44
  */
44
- chat(prompt: string): Observable<string>;
45
+ chat(prompt: string, options?: AiAssistantChatOptions): Observable<string>;
45
46
  /**
46
47
  * Retrieves a context reference for the current profile. A context reference can be used to add a new context entry
47
48
  * to the profile, or update/delete an existing entry context.
@@ -6,3 +6,4 @@ export { deserializeQuery } from './query/deserializer';
6
6
  export { Squid, SquidOptions } from './squid';
7
7
  export { TransactionId } from './types';
8
8
  export { GraphQLClient } from './graphql-client';
9
+ export { AiAssistantProfileReference } from './ai-assistant-client';
@@ -0,0 +1,32 @@
1
+ export declare class RateLimiter {
2
+ private readonly capacity;
3
+ private readonly seconds;
4
+ private tokens;
5
+ private lastRefillTimestamp;
6
+ private readonly refillRatePerMs;
7
+ /**
8
+ * Creates a new rate limiter. It limits the number of requests using two parameters:
9
+ * - capacity: the maximum number of tokens (actions) that can be stored at any given time
10
+ * - seconds: the number of seconds it takes to refill the bucket to its maximum capacity
11
+ *
12
+ * We then can calculate the refillRatePerMs: the number of tokens (actions) that are added to the bucket every
13
+ * millisecond
14
+ *
15
+ * Example:
16
+ * Say we want to allow maximum 60 requests in a period of 5 seconds. We can create a rate limiter with:
17
+ * - capacity: 60
18
+ * - seconds: 5
19
+ * And we will get refillRatePerMs: 60 / (5 * 1000) = 0.012
20
+ *
21
+ * To use:
22
+ * const rateLimiter = new RateLimiter(60, 5);
23
+ * await rateLimiter.consume();
24
+ *
25
+ * @param capacity
26
+ * @param refillRatePerMs
27
+ */
28
+ constructor(capacity: number, seconds: number);
29
+ consume(): Promise<void>;
30
+ private attemptConsume;
31
+ private refill;
32
+ }
@@ -9,6 +9,7 @@ export declare class RpcManager {
9
9
  private readonly clientIdService;
10
10
  private readonly staticHeaders;
11
11
  private readonly onGoingRpcCounter;
12
+ private readonly rateLimiters;
12
13
  constructor(region: SupportedSquidRegion, appId: string, destructManager: DestructManager, headers: Record<string, string> | undefined, authManager: AuthManager, clientIdService: ClientIdService);
13
14
  awaitAllSettled(): Promise<void>;
14
15
  setStaticHeader(key: string, value: string): void;
@@ -17,6 +18,7 @@ export declare class RpcManager {
17
18
  private ready;
18
19
  post<T>(path: string, message: any, files?: File[]): Promise<T>;
19
20
  private parseResponse;
21
+ private getRateLimiterBucket;
20
22
  }
21
23
  export declare class RpcError extends Error {
22
24
  readonly statusCode: number;
@@ -6,7 +6,7 @@ export declare class SecretClient {
6
6
  get(key: SecretKey): Promise<SecretEntry | undefined>;
7
7
  getAll(): Promise<Record<SecretKey, SecretEntry>>;
8
8
  upsert(key: SecretKey, value: SecretValue): Promise<SecretEntry>;
9
- upsertMany(entries: Array<SetSecretRequestEntry>): Promise<SecretEntry>;
9
+ upsertMany(entries: Array<SetSecretRequestEntry>): Promise<Array<SecretEntry>>;
10
10
  delete(key: SecretKey): Promise<void>;
11
11
  deleteMany(keys: Array<SecretKey>): Promise<void>;
12
12
  get apiKeys(): ApiKeysSecretClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.125",
3
+ "version": "1.0.127",
4
4
  "description": "A typescript implementation of the Squid client",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/typescript-client/src/index.d.ts",
@@ -46,6 +46,7 @@
46
46
  "@typescript-eslint/eslint-plugin": "^5.0.0",
47
47
  "@typescript-eslint/parser": "^5.0.0",
48
48
  "@webpack-cli/generators": "^3.0.0",
49
+ "assertic": "^1.0.0",
49
50
  "copy-webpack-plugin": "^11.0.0",
50
51
  "cpx": "^1.5.0",
51
52
  "eslint": "8.22.0",
@@ -1,2 +0,0 @@
1
- export declare function isNotNullish<T>(t: T | undefined | null): t is T;
2
- export declare function isString(t: unknown): t is string;