@squidcloud/client 1.0.73 → 1.0.75
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/common/src/communication.types.d.ts +1 -1
- package/dist/common/src/context.types.d.ts +12 -4
- package/dist/common/src/integrations/auth.types.d.ts +7 -0
- package/dist/common/src/integrations/index.d.ts +4 -2
- package/dist/common/src/mutation.context.d.ts +3 -1
- package/dist/common/src/query.types.d.ts +1 -2
- package/dist/common/src/utils/serialization.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.LICENSE.txt +0 -17
- package/dist/typescript-client/src/ai-assistant-client.d.ts +115 -14
- package/dist/typescript-client/src/ai-client.factory.d.ts +1 -3
- package/dist/typescript-client/src/client-id.service.d.ts +2 -1
- package/dist/typescript-client/src/connection-details.d.ts +23 -0
- package/dist/typescript-client/src/mutation/mutation-sender.d.ts +1 -3
- package/dist/typescript-client/src/named-query.manager.d.ts +1 -3
- package/dist/typescript-client/src/squid.d.ts +22 -0
- package/package.json +1 -1
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/*! *****************************************************************************
|
|
2
|
-
Copyright (c) Microsoft Corporation.
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */
|
|
15
|
-
|
|
16
|
-
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
17
|
-
|
|
18
1
|
/**
|
|
19
2
|
* @license
|
|
20
3
|
* Lodash <https://lodash.com/>
|
|
@@ -1,66 +1,167 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IntegrationId, OpenAiModelName } from '@squidcloud/common';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { ClientIdService } from './client-id.service';
|
|
4
3
|
import { RpcManager } from './rpc.manager';
|
|
5
4
|
import { SocketManager } from './socket.manager';
|
|
6
5
|
export declare class AiAssistantClient {
|
|
7
|
-
private readonly clientIdService;
|
|
8
6
|
private readonly rpcManager;
|
|
9
7
|
private readonly socketManager;
|
|
10
8
|
private readonly integrationId;
|
|
11
9
|
private readonly ongoingChatRequests;
|
|
12
|
-
constructor(
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
constructor(rpcManager: RpcManager, socketManager: SocketManager, integrationId: IntegrationId);
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves a profile reference for the provided id. A profile reference
|
|
13
|
+
* can be used to create and update profiles, add instructions and context
|
|
14
|
+
* and start chats.
|
|
15
|
+
*
|
|
16
|
+
* @param id - The id of the profile.
|
|
17
|
+
* @returns The profile reference.
|
|
18
|
+
*/
|
|
19
|
+
profile(id: string): AiAssistantProfileReference;
|
|
20
|
+
/**
|
|
21
|
+
* Sends a prompt to the specified profile id.
|
|
22
|
+
*
|
|
23
|
+
* @param profileId - The profile id.
|
|
24
|
+
* @param prompt - The prompt.
|
|
25
|
+
* @returns An observable that emits when a new response token is received. The emitted value is the entire response
|
|
26
|
+
* that has been received so far.
|
|
27
|
+
*/
|
|
15
28
|
chat(profileId: string, prompt: string): Observable<string>;
|
|
16
29
|
private handleChatResponse;
|
|
17
30
|
}
|
|
18
|
-
declare class
|
|
31
|
+
declare class AiAssistantProfileReference {
|
|
19
32
|
private readonly client;
|
|
20
33
|
private readonly integrationId;
|
|
21
34
|
private readonly profileId;
|
|
22
35
|
constructor(client: AiAssistantClient, integrationId: IntegrationId, profileId: string);
|
|
36
|
+
/**
|
|
37
|
+
* Sends a prompt to the current profile.
|
|
38
|
+
*
|
|
39
|
+
* @param prompt - The prompt.
|
|
40
|
+
* @returns An observable that emits when a new response token is received. The emitted value is the entire response
|
|
41
|
+
* that has been received so far.
|
|
42
|
+
*/
|
|
23
43
|
chat(prompt: string): Observable<string>;
|
|
24
|
-
|
|
25
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves a context reference for the current profile. A context reference can be used to add a new context entry
|
|
46
|
+
* to the profile, or update/delete an existing entry context.
|
|
47
|
+
*
|
|
48
|
+
* @param id - The id of the context entry. If no id is passed, an id will be
|
|
49
|
+
* generated and the reference will point to a new context entry.
|
|
50
|
+
* @returns The context reference.
|
|
51
|
+
*/
|
|
52
|
+
context(id?: string): AiAssistantContextReference;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves an instruction reference for the current profile. An instruction reference can be used to add a new
|
|
55
|
+
* instruction entry to the profile, or update/delete an existing instruction entry.
|
|
56
|
+
*
|
|
57
|
+
* @param id - The id of the instruction entry. If no id is passed, an id will be
|
|
58
|
+
* generated and the reference will point to a new instruction entry.
|
|
59
|
+
* @returns The instruction reference.
|
|
60
|
+
*/
|
|
61
|
+
instruction(id?: string): AiAssistantInstructionReference;
|
|
62
|
+
/**
|
|
63
|
+
* Adds a new profile to the assistant. This will result in an error if a profile already exists with the same id.
|
|
64
|
+
*
|
|
65
|
+
* @param data An object containing options for creating the profile.
|
|
66
|
+
* @param data.modelName - The name of the OpenAI model (`gpt-3.5 or `gpt-4`).
|
|
67
|
+
* @returns A promise that resolves when the profile is successfully created.
|
|
68
|
+
*/
|
|
26
69
|
insert(data: {
|
|
27
70
|
modelName: OpenAiModelName;
|
|
28
|
-
strictContext: boolean;
|
|
29
71
|
}): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Updates an existing assistant profile. This will result in an error if a profile has not yet been created for the
|
|
74
|
+
* current profile id.
|
|
75
|
+
*
|
|
76
|
+
* @param data An object containing options for updating the profile.
|
|
77
|
+
* @param data.modelName - The name of the OpenAI model (`gpt-3.5 or `gpt-4`).
|
|
78
|
+
* @returns A promise that resolves when the profile is successfully updated.
|
|
79
|
+
*/
|
|
30
80
|
update(data: {
|
|
31
|
-
modelName
|
|
32
|
-
strictContext: boolean;
|
|
81
|
+
modelName: OpenAiModelName;
|
|
33
82
|
}): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Deletes an existing assistant profile. This will result in an error if a profile has not yet been created for the
|
|
85
|
+
* current profile id.
|
|
86
|
+
*
|
|
87
|
+
* @returns A promise that resolves when the profile is successfully deleted.
|
|
88
|
+
*/
|
|
34
89
|
delete(): Promise<void>;
|
|
35
90
|
}
|
|
36
|
-
declare class
|
|
91
|
+
declare class AiAssistantContextReference {
|
|
37
92
|
private readonly client;
|
|
38
93
|
private readonly integrationId;
|
|
39
94
|
private readonly profileId;
|
|
40
95
|
private readonly id;
|
|
41
96
|
constructor(client: AiAssistantClient, integrationId: IntegrationId, profileId: string, id?: string);
|
|
97
|
+
/**
|
|
98
|
+
* Adds a new context entry to the assistant profile. This will result in an error if an entry already exists with
|
|
99
|
+
* the same id.
|
|
100
|
+
*
|
|
101
|
+
* @param data An object containing options for creating the entry.
|
|
102
|
+
* @param data.title - The title of the entry.
|
|
103
|
+
* @param data.context - The context data.
|
|
104
|
+
* @returns A promise that resolves when the context is successfully created.
|
|
105
|
+
*/
|
|
42
106
|
insert(data: {
|
|
43
107
|
title: string;
|
|
44
108
|
context: string;
|
|
45
109
|
}): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Updates an existing context entry on the assistant profile. This will result in an error if an entry has not yet
|
|
112
|
+
* been created for the current context id.
|
|
113
|
+
*
|
|
114
|
+
* @param data An object containing options for updated the entry.
|
|
115
|
+
* @param data.title - The title of the entry.
|
|
116
|
+
* @param data.context - The context data.
|
|
117
|
+
* @returns A promise that resolves when the context is successfully updated.
|
|
118
|
+
*/
|
|
46
119
|
update(data: {
|
|
47
120
|
title?: string;
|
|
48
121
|
context?: string;
|
|
49
122
|
}): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Deletes an existing context entry on the assistant profile. This will result in an error if an entry has not yet
|
|
125
|
+
* been created for the current context id.
|
|
126
|
+
*
|
|
127
|
+
* @returns A promise that resolves when the context is successfully deleted.
|
|
128
|
+
*/
|
|
50
129
|
delete(): Promise<void>;
|
|
51
130
|
}
|
|
52
|
-
declare class
|
|
131
|
+
declare class AiAssistantInstructionReference {
|
|
53
132
|
private readonly client;
|
|
54
133
|
private readonly integrationId;
|
|
55
134
|
private readonly profileId;
|
|
56
135
|
private readonly id;
|
|
57
136
|
constructor(client: AiAssistantClient, integrationId: IntegrationId, profileId: string, id?: string);
|
|
137
|
+
/**
|
|
138
|
+
* Adds a new instruction entry to the assistant profile. This will result in an error if an entry already exists with
|
|
139
|
+
* the same id.
|
|
140
|
+
*
|
|
141
|
+
* @param data An object containing options for creating the entry.
|
|
142
|
+
* @param data.instruction - The instruction data.
|
|
143
|
+
* @returns A promise that resolves when the instruction is successfully created.
|
|
144
|
+
*/
|
|
58
145
|
insert(data: {
|
|
59
146
|
instruction: string;
|
|
60
147
|
}): Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* Updates an existing instruction entry on the assistant profile. This will result in an error if an entry has not
|
|
150
|
+
* yet been created for the current instruction id.
|
|
151
|
+
*
|
|
152
|
+
* @param data An object containing options for updated the entry.
|
|
153
|
+
* @param data.instruction - The instruction data.
|
|
154
|
+
* @returns A promise that resolves when the instruction is successfully updated.
|
|
155
|
+
*/
|
|
61
156
|
update(data: {
|
|
62
157
|
instruction: string;
|
|
63
158
|
}): Promise<void>;
|
|
159
|
+
/**
|
|
160
|
+
* Deletes an existing instruction entry on the assistant profile. This will result in an error if an entry has not
|
|
161
|
+
* yet been created for the current instruction id.
|
|
162
|
+
*
|
|
163
|
+
* @returns A promise that resolves when the instruction is successfully deleted.
|
|
164
|
+
*/
|
|
64
165
|
delete(): Promise<void>;
|
|
65
166
|
}
|
|
66
167
|
export {};
|
|
@@ -2,12 +2,10 @@ import { IntegrationId } from '@squidcloud/common';
|
|
|
2
2
|
import { AiAssistantClient } from './ai-assistant-client';
|
|
3
3
|
import { RpcManager } from './rpc.manager';
|
|
4
4
|
import { SocketManager } from './socket.manager';
|
|
5
|
-
import { ClientIdService } from './client-id.service';
|
|
6
5
|
export declare class AiClientFactory {
|
|
7
|
-
private readonly clientIdService;
|
|
8
6
|
private readonly rpcManager;
|
|
9
7
|
private readonly socketManager;
|
|
10
8
|
private readonly assistantsMap;
|
|
11
|
-
constructor(
|
|
9
|
+
constructor(rpcManager: RpcManager, socketManager: SocketManager);
|
|
12
10
|
getAssistant(integrationId: IntegrationId): AiAssistantClient;
|
|
13
11
|
}
|
|
@@ -12,8 +12,9 @@ import { DestructManager } from './destruct.manager';
|
|
|
12
12
|
export declare class ClientIdService {
|
|
13
13
|
private readonly destructManager;
|
|
14
14
|
private readonly clientTooOldSubject;
|
|
15
|
-
private
|
|
15
|
+
private readonly clientIdSubject;
|
|
16
16
|
constructor(destructManager: DestructManager);
|
|
17
|
+
observeClientId(): Observable<ClientId>;
|
|
17
18
|
observeClientTooOld(): Observable<void>;
|
|
18
19
|
/** there was a long-term disconnection of the socket */
|
|
19
20
|
notifyClientTooOld(): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ClientId } from '@squidcloud/common';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
/**
|
|
4
|
+
* Provides information about the connection to the Squid Server.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ConnectionDetails {
|
|
7
|
+
private readonly clientIdService;
|
|
8
|
+
private readonly socketManager;
|
|
9
|
+
private isConnected;
|
|
10
|
+
/** Whether the Squid Client SDK is currently connected to the Squid Server. */
|
|
11
|
+
get connected(): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* A unique client ID that is assigned to the client. This client ID is also available to the different backend
|
|
14
|
+
* function in the context object.
|
|
15
|
+
* Note: The client ID may change after a long disconnect.
|
|
16
|
+
*/
|
|
17
|
+
get clientId(): ClientId;
|
|
18
|
+
/**
|
|
19
|
+
* Returns an observable that emits true when the client is connected to the server and false when the client is
|
|
20
|
+
* disconnected from the server.
|
|
21
|
+
*/
|
|
22
|
+
observeConnected(): Observable<boolean>;
|
|
23
|
+
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { IntegrationId, LockManager, MutateResponse, Mutation } from '@squidcloud/common';
|
|
2
2
|
import { QuerySubscriptionManager } from '../query/query-subscription.manager';
|
|
3
3
|
import { RpcManager } from '../rpc.manager';
|
|
4
|
-
import { ClientIdService } from '../client-id.service';
|
|
5
4
|
export declare class MutationSender {
|
|
6
|
-
private readonly clientIdService;
|
|
7
5
|
private readonly rpcManager;
|
|
8
6
|
private readonly lockManager;
|
|
9
7
|
private readonly querySubscriptionManager;
|
|
10
|
-
constructor(
|
|
8
|
+
constructor(rpcManager: RpcManager, lockManager: LockManager, querySubscriptionManager: QuerySubscriptionManager);
|
|
11
9
|
sendMutations(mutations: Array<Mutation>, integrationId: IntegrationId): Promise<MutateResponse>;
|
|
12
10
|
}
|
|
@@ -2,13 +2,11 @@ import { IntegrationId, QueryName } from '@squidcloud/common';
|
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { RpcManager } from './rpc.manager';
|
|
4
4
|
import { SocketManager } from './socket.manager';
|
|
5
|
-
import { ClientIdService } from './client-id.service';
|
|
6
5
|
export declare class NamedQueryManager {
|
|
7
|
-
private readonly clientIdService;
|
|
8
6
|
private readonly rpcManager;
|
|
9
7
|
private readonly socketManager;
|
|
10
8
|
private readonly ongoingNamedQueryExecutions;
|
|
11
|
-
constructor(
|
|
9
|
+
constructor(rpcManager: RpcManager, socketManager: SocketManager);
|
|
12
10
|
executeNamedQueryAndSubscribe<T>(integrationId: IntegrationId, queryName: QueryName, params: Record<string, any>): Observable<T>;
|
|
13
11
|
private handleNamedQueryResponse;
|
|
14
12
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ApiEndpointId, ApiKey, AppId, CollectionName, DocumentData, EnvironmentId, IntegrationId, QueryName, SquidDeveloperId, SupportedSquidRegion } from '@squidcloud/common';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
+
import { AiAssistantClient } from './ai-assistant-client';
|
|
3
4
|
import { CollectionReference } from './collection-reference';
|
|
4
5
|
import { DistributedLock } from './distributed-lock.manager';
|
|
5
6
|
import { GraphQLClient } from './graphql-client';
|
|
6
7
|
import { TransactionId } from './types';
|
|
8
|
+
import { ConnectionDetails } from './connection-details';
|
|
7
9
|
/** The different options that can be used to initialize a Squid instance. */
|
|
8
10
|
export interface SquidOptions {
|
|
9
11
|
/**
|
|
@@ -68,6 +70,7 @@ export declare class Squid {
|
|
|
68
70
|
private readonly authManager;
|
|
69
71
|
private readonly clientIdService;
|
|
70
72
|
private readonly aiClientFactory;
|
|
73
|
+
private readonly _connectionDetails;
|
|
71
74
|
private static readonly squidInstancesMap;
|
|
72
75
|
/**
|
|
73
76
|
* Creates a new instance of Squid with the given options.
|
|
@@ -175,6 +178,23 @@ export declare class Squid {
|
|
|
175
178
|
* @returns A GraphQL client for the given integration.
|
|
176
179
|
*/
|
|
177
180
|
graphql: (integrationId: IntegrationId) => GraphQLClient;
|
|
181
|
+
/**
|
|
182
|
+
* Returns a set of AI specific clients. Currently, the only supported client is the AI Assistant, which is accessed
|
|
183
|
+
* through the `assistant`.
|
|
184
|
+
*
|
|
185
|
+
* @returns A set of AI specific clients.
|
|
186
|
+
*/
|
|
187
|
+
ai: () => {
|
|
188
|
+
/**
|
|
189
|
+
* Returns an AI Assistant client for the given integration. The AI Assistant client can be used to build and chat
|
|
190
|
+
* with custom AI profiles. For more information about the AI Assistant in Squid, please refer to the documentation
|
|
191
|
+
* at {@link https://docs.squid.cloud/docs/integrations/ai/ai-assistant}.
|
|
192
|
+
*
|
|
193
|
+
* @param integrationId The id of the AI Assistant integration.
|
|
194
|
+
* @returns An AI Assistant client.
|
|
195
|
+
*/
|
|
196
|
+
assistant: (integrationId: IntegrationId) => AiAssistantClient;
|
|
197
|
+
};
|
|
178
198
|
/**
|
|
179
199
|
* Returns a distributed lock for the given mutex. The lock can be used to synchronize access to a shared resource.
|
|
180
200
|
* The lock will be released when the release method on the returned object is invoked or whenever the connection
|
|
@@ -192,5 +212,7 @@ export declare class Squid {
|
|
|
192
212
|
* @returns A promise that resolves when the destruct process is complete.
|
|
193
213
|
*/
|
|
194
214
|
destruct: () => Promise<void>;
|
|
215
|
+
/** Provides information about the connection to the Squid Server. */
|
|
216
|
+
connectionDetails: () => ConnectionDetails;
|
|
195
217
|
private validateNotDestructed;
|
|
196
218
|
}
|