@squidcloud/client 1.0.145 → 1.0.146-beta

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.
Files changed (206) hide show
  1. package/dist/cjs/index.js +1 -53942
  2. package/dist/esm/index.js +1 -0
  3. package/dist/internal-common/src/metric-name.d.ts +9 -0
  4. package/dist/internal-common/src/public-types/ai-agent-integrations.public-types.d.ts +47 -0
  5. package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +895 -0
  6. package/dist/internal-common/src/public-types/ai-assistant.public-types.d.ts +31 -0
  7. package/dist/internal-common/src/public-types/ai-common.public-types.d.ts +185 -0
  8. package/dist/internal-common/src/public-types/ai-knowledge-base.public-types.d.ts +431 -0
  9. package/dist/internal-common/src/public-types/ai-matchmaking.public-types.d.ts +186 -0
  10. package/dist/internal-common/src/public-types/ai-query.public-types.d.ts +170 -0
  11. package/dist/internal-common/src/public-types/api-client.public-types.d.ts +9 -0
  12. package/dist/internal-common/src/public-types/api.public-types.d.ts +91 -0
  13. package/dist/internal-common/src/public-types/backend.public-types.d.ts +50 -0
  14. package/dist/{common/src/backend-function.schemas.d.ts → internal-common/src/public-types/code-executor.public-types.d.ts} +1 -1
  15. package/dist/internal-common/src/public-types/communication.public-types.d.ts +30 -0
  16. package/dist/internal-common/src/public-types/context.public-types.d.ts +83 -0
  17. package/dist/internal-common/src/public-types/document.public-types.d.ts +71 -0
  18. package/dist/internal-common/src/public-types/external-auth/external-auth.public-types.d.ts +39 -0
  19. package/dist/internal-common/src/public-types/extraction.public-types.d.ts +183 -0
  20. package/dist/internal-common/src/public-types/http-status.public-types.d.ts +415 -0
  21. package/dist/internal-common/src/public-types/integration.public-types.d.ts +51 -0
  22. package/dist/internal-common/src/public-types/job.public-types.d.ts +59 -0
  23. package/dist/internal-common/src/public-types/metric.public-types.d.ts +154 -0
  24. package/dist/internal-common/src/public-types/openapi.public-types.d.ts +9 -0
  25. package/dist/internal-common/src/public-types/query.public-types.d.ts +113 -0
  26. package/dist/internal-common/src/public-types/regions.public-types.d.ts +4 -0
  27. package/dist/internal-common/src/public-types/scheduler.public-types.d.ts +43 -0
  28. package/dist/{common/src/schema/schema.types.d.ts → internal-common/src/public-types/schema.public-types.d.ts} +54 -54
  29. package/dist/internal-common/src/public-types/secret.public-types.d.ts +51 -0
  30. package/dist/internal-common/src/public-types/serialized-query.public-types.d.ts +60 -0
  31. package/dist/internal-common/src/public-types/socket.public-types.d.ts +4 -0
  32. package/dist/{common/src/types.d.ts → internal-common/src/public-types/typescript.public-types.d.ts} +20 -14
  33. package/dist/internal-common/src/public-types/web.public-types.d.ts +93 -0
  34. package/dist/internal-common/src/public-types-backend/api-call.public-context.d.ts +30 -0
  35. package/dist/internal-common/src/public-types-backend/mutation.public-context.d.ts +148 -0
  36. package/dist/internal-common/src/public-types-backend/native-query.public-context.d.ts +72 -0
  37. package/dist/{common/src/query/query-context.d.ts → internal-common/src/public-types-backend/query.public-context.d.ts} +177 -137
  38. package/dist/{common/src/ai-chatbot.schemas.d.ts → internal-common/src/public-utils/context-utils.d.ts} +1 -1
  39. package/dist/internal-common/src/public-utils/id-utils.d.ts +44 -0
  40. package/dist/internal-common/src/types/ai-agent.types.d.ts +199 -0
  41. package/dist/{common/src/mutation.schemas.d.ts → internal-common/src/types/ai-assistant.types.d.ts} +1 -1
  42. package/dist/internal-common/src/types/ai-knowledge-base.types.d.ts +202 -0
  43. package/dist/internal-common/src/types/ai-matchmaking.types.d.ts +59 -0
  44. package/dist/{common/src → internal-common/src/types}/backend-function.types.d.ts +1 -1
  45. package/dist/internal-common/src/types/communication.types.d.ts +1 -0
  46. package/dist/internal-common/src/types/document.types.d.ts +1 -0
  47. package/dist/internal-common/src/types/file.types.d.ts +6 -0
  48. package/dist/internal-common/src/types/headers.types.d.ts +17 -0
  49. package/dist/internal-common/src/types/mutation.types.d.ts +1 -0
  50. package/dist/internal-common/src/types/notification.types.d.ts +5 -0
  51. package/dist/internal-common/src/types/observability.types.d.ts +78 -0
  52. package/dist/internal-common/src/types/query.types.d.ts +13 -0
  53. package/dist/internal-common/src/types/secret.types.d.ts +7 -0
  54. package/dist/internal-common/src/types/socket.types.d.ts +1 -0
  55. package/dist/internal-common/src/types/stage.d.ts +9 -0
  56. package/dist/{common/src → internal-common/src/types}/time-units.d.ts +1 -1
  57. package/dist/internal-common/src/types/url-shortener.types.d.ts +41 -0
  58. package/dist/internal-common/src/utils/array.d.ts +7 -0
  59. package/dist/internal-common/src/utils/e2e-test-utils.d.ts +2 -0
  60. package/dist/{common → internal-common}/src/utils/global.utils.d.ts +1 -1
  61. package/dist/internal-common/src/utils/http.d.ts +5 -0
  62. package/dist/{common → internal-common}/src/utils/lock.manager.d.ts +14 -14
  63. package/dist/internal-common/src/utils/metric-utils.d.ts +4 -0
  64. package/dist/internal-common/src/utils/metrics.types.d.ts +7 -0
  65. package/dist/internal-common/src/utils/object.d.ts +58 -0
  66. package/dist/internal-common/src/utils/serialization.d.ts +17 -0
  67. package/dist/internal-common/src/utils/squid.constants.d.ts +1 -0
  68. package/dist/internal-common/src/utils/trace-id-generator.d.ts +1 -0
  69. package/dist/internal-common/src/utils/validation.d.ts +19 -0
  70. package/dist/{common → internal-common}/src/websocket.impl.d.ts +26 -21
  71. package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -1239
  72. package/dist/typescript-client/src/admin-client.d.ts +23 -0
  73. package/dist/typescript-client/src/agent/ai-agent-client-reference.d.ts +181 -0
  74. package/dist/typescript-client/src/agent/ai-agent-client.d.ts +37 -0
  75. package/dist/typescript-client/src/agent/ai-agent-client.types.d.ts +69 -0
  76. package/dist/typescript-client/src/ai-assistant-client.d.ts +72 -73
  77. package/dist/typescript-client/src/ai-audio-client.d.ts +25 -0
  78. package/dist/typescript-client/src/ai-client.d.ts +129 -0
  79. package/dist/typescript-client/src/ai-files-client.d.ts +33 -0
  80. package/dist/typescript-client/src/ai-image-client.d.ts +25 -0
  81. package/dist/typescript-client/src/ai-knowledge-base/ai-knowledge-base-client-reference.d.ts +86 -0
  82. package/dist/typescript-client/src/ai-knowledge-base/ai-knowledge-base-client.d.ts +28 -0
  83. package/dist/typescript-client/src/ai-matchmaking-client.d.ts +99 -0
  84. package/dist/typescript-client/src/api-client.d.ts +69 -0
  85. package/dist/typescript-client/src/auth.manager.d.ts +11 -26
  86. package/dist/typescript-client/src/backend-function.manager.d.ts +1 -9
  87. package/dist/typescript-client/src/client-customization.utils.d.ts +1 -0
  88. package/dist/typescript-client/src/client-id.service.d.ts +1 -27
  89. package/dist/typescript-client/src/collection-reference.d.ts +105 -80
  90. package/dist/typescript-client/src/collection-reference.factory.d.ts +1 -13
  91. package/dist/typescript-client/src/connection-details.d.ts +24 -23
  92. package/dist/typescript-client/src/console-utils.d.ts +1 -0
  93. package/dist/typescript-client/src/data.manager.d.ts +1 -173
  94. package/dist/typescript-client/src/destruct.manager.d.ts +1 -12
  95. package/dist/typescript-client/src/distributed-lock.manager.d.ts +39 -16
  96. package/dist/typescript-client/src/document-identity.service.d.ts +1 -12
  97. package/dist/typescript-client/src/document-reference.d.ts +151 -140
  98. package/dist/typescript-client/src/document-reference.factory.d.ts +1 -13
  99. package/dist/typescript-client/src/document-store.d.ts +1 -14
  100. package/dist/typescript-client/src/execute-function-options.d.ts +73 -0
  101. package/dist/typescript-client/src/external-auth-client.d.ts +36 -0
  102. package/dist/typescript-client/src/extraction-client.d.ts +32 -0
  103. package/dist/typescript-client/src/file-args-transformer.d.ts +1 -0
  104. package/dist/typescript-client/src/file-utils.d.ts +1 -0
  105. package/dist/typescript-client/src/index.d.ts +63 -9
  106. package/dist/typescript-client/src/integration-client.d.ts +60 -0
  107. package/dist/typescript-client/src/job-client.d.ts +32 -0
  108. package/dist/typescript-client/src/mutation/mutation-sender.d.ts +1 -10
  109. package/dist/typescript-client/src/native-query-manager.d.ts +1 -7
  110. package/dist/typescript-client/src/notification-client.d.ts +20 -0
  111. package/dist/typescript-client/src/observability-client.d.ts +43 -0
  112. package/dist/typescript-client/src/public-types.d.ts +30 -0
  113. package/dist/typescript-client/src/public-utils.d.ts +1 -0
  114. package/dist/typescript-client/src/query/deserializer.d.ts +10 -3
  115. package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +316 -161
  116. package/dist/typescript-client/src/query/local-query-manager.d.ts +1 -9
  117. package/dist/{common → typescript-client}/src/query/pagination.d.ts +65 -62
  118. package/dist/typescript-client/src/query/query-builder.factory.d.ts +228 -77
  119. package/dist/typescript-client/src/query/query-sender.d.ts +1 -33
  120. package/dist/typescript-client/src/query/query-subscription.manager.d.ts +1 -130
  121. package/dist/typescript-client/src/query/query.types.d.ts +16 -49
  122. package/dist/typescript-client/src/query/snapshot-emitter.d.ts +41 -0
  123. package/dist/typescript-client/src/query-utils.d.ts +18 -0
  124. package/dist/typescript-client/src/queue.manager.d.ts +12 -0
  125. package/dist/typescript-client/src/rate-limiter.d.ts +1 -32
  126. package/dist/typescript-client/src/rpc.manager.d.ts +1 -30
  127. package/dist/typescript-client/src/scheduler-client.d.ts +31 -0
  128. package/dist/typescript-client/src/secret.client.d.ts +96 -22
  129. package/dist/typescript-client/src/socket.manager.d.ts +1 -43
  130. package/dist/typescript-client/src/squid-http-client.d.ts +11 -0
  131. package/dist/typescript-client/src/squid.d.ts +378 -269
  132. package/dist/typescript-client/src/state/state.service.spec.d.ts +1 -1
  133. package/dist/typescript-client/src/storage-client.d.ts +145 -0
  134. package/dist/typescript-client/src/types.d.ts +27 -2
  135. package/dist/typescript-client/src/version.d.ts +5 -0
  136. package/dist/typescript-client/src/web-client.d.ts +63 -0
  137. package/dist/typescript-client/src/webhook.manager.d.ts +10 -0
  138. package/package.json +34 -18
  139. package/dist/common/src/ai-assistant.types.d.ts +0 -25
  140. package/dist/common/src/ai-chatbot.context.d.ts +0 -12
  141. package/dist/common/src/ai-chatbot.types.d.ts +0 -27
  142. package/dist/common/src/api-call.context.d.ts +0 -13
  143. package/dist/common/src/api.types.d.ts +0 -4
  144. package/dist/common/src/application.schemas.d.ts +0 -66
  145. package/dist/common/src/application.types.d.ts +0 -143
  146. package/dist/common/src/backend-run.types.d.ts +0 -2
  147. package/dist/common/src/bundle-api.types.d.ts +0 -43
  148. package/dist/common/src/bundle-data.types.d.ts +0 -5
  149. package/dist/common/src/communication.types.d.ts +0 -8
  150. package/dist/common/src/context.types.d.ts +0 -40
  151. package/dist/common/src/distributed-lock.context.d.ts +0 -4
  152. package/dist/common/src/document.types.d.ts +0 -22
  153. package/dist/common/src/graphql.context.d.ts +0 -7
  154. package/dist/common/src/graphql.types.d.ts +0 -9
  155. package/dist/common/src/heartbeat.types.d.ts +0 -1
  156. package/dist/common/src/http-status.enum.d.ts +0 -50
  157. package/dist/common/src/index.d.ts +0 -57
  158. package/dist/common/src/integrations/ai_chatbot.types.d.ts +0 -31
  159. package/dist/common/src/integrations/api.types.d.ts +0 -80
  160. package/dist/common/src/integrations/auth.types.d.ts +0 -47
  161. package/dist/common/src/integrations/database.types.d.ts +0 -274
  162. package/dist/common/src/integrations/index.d.ts +0 -134
  163. package/dist/common/src/integrations/observability.types.d.ts +0 -23
  164. package/dist/common/src/logger.types.d.ts +0 -21
  165. package/dist/common/src/metrics.types.d.ts +0 -1
  166. package/dist/common/src/mutation.context.d.ts +0 -14
  167. package/dist/common/src/mutation.types.d.ts +0 -53
  168. package/dist/common/src/named-query.context.d.ts +0 -4
  169. package/dist/common/src/named-query.schemas.d.ts +0 -1
  170. package/dist/common/src/named-query.types.d.ts +0 -1
  171. package/dist/common/src/native-query.context.d.ts +0 -7
  172. package/dist/common/src/native-query.types.d.ts +0 -16
  173. package/dist/common/src/query/base-query-builder.d.ts +0 -147
  174. package/dist/common/src/query/index.d.ts +0 -4
  175. package/dist/common/src/query/serialized-query.types.d.ts +0 -24
  176. package/dist/common/src/query.types.d.ts +0 -64
  177. package/dist/common/src/regions.d.ts +0 -1
  178. package/dist/common/src/secret.schemas.d.ts +0 -1
  179. package/dist/common/src/secret.types.d.ts +0 -22
  180. package/dist/common/src/security.types.d.ts +0 -1
  181. package/dist/common/src/socket.schemas.d.ts +0 -1
  182. package/dist/common/src/socket.types.d.ts +0 -5
  183. package/dist/common/src/trigger.types.d.ts +0 -1
  184. package/dist/common/src/utils/array.d.ts +0 -1
  185. package/dist/common/src/utils/assert.d.ts +0 -1
  186. package/dist/common/src/utils/error.d.ts +0 -4
  187. package/dist/common/src/utils/http.d.ts +0 -2
  188. package/dist/common/src/utils/id.d.ts +0 -2
  189. package/dist/common/src/utils/object.d.ts +0 -5
  190. package/dist/common/src/utils/serialization.d.ts +0 -6
  191. package/dist/common/src/utils/transforms.d.ts +0 -18
  192. package/dist/common/src/utils/url.d.ts +0 -1
  193. package/dist/common/src/utils/validation.d.ts +0 -25
  194. package/dist/common/src/webhook-response.d.ts +0 -1
  195. package/dist/typescript-client/src/ai-chatbot-client.d.ts +0 -174
  196. package/dist/typescript-client/src/ai-chatbot-client.factory.d.ts +0 -8
  197. package/dist/typescript-client/src/ai.types.d.ts +0 -61
  198. package/dist/typescript-client/src/api.manager.d.ts +0 -11
  199. package/dist/typescript-client/src/graphql-client.d.ts +0 -14
  200. package/dist/typescript-client/src/graphql-client.factory.d.ts +0 -11
  201. package/dist/typescript-client/src/named-query.manager.d.ts +0 -11
  202. package/dist/typescript-client/src/state/action.applier.d.ts +0 -7
  203. package/dist/typescript-client/src/state/actions.d.ts +0 -29
  204. package/dist/typescript-client/src/state/path_trie.d.ts +0 -27
  205. package/dist/typescript-client/src/state/state.service.d.ts +0 -22
  206. package/dist/typescript-client/src/testing/setup-tests.d.ts +0 -1
@@ -0,0 +1,23 @@
1
+ import { IntegrationClient } from './integration-client';
2
+ import { SecretClient } from './secret.client';
3
+ /**
4
+ * AdminClient provides access to application administrative operations,
5
+ * including integrations and secrets management.
6
+ * @category Platform
7
+ */
8
+ export declare class AdminClient {
9
+ private readonly rpcManager;
10
+ private readonly region;
11
+ private readonly appId;
12
+ private readonly consoleRegion;
13
+ private readonly integrationClient;
14
+ private readonly secretClient;
15
+ /**
16
+ * Returns the IntegrationClient for managing integrations.
17
+ */
18
+ integrations(): IntegrationClient;
19
+ /**
20
+ * Returns the SecretClient for managing secrets.
21
+ */
22
+ secrets(): SecretClient;
23
+ }
@@ -0,0 +1,181 @@
1
+ import { Observable } from 'rxjs';
2
+ import { AiAgent, AiChatMessage, AiChatModelSelection, AiConnectedAgentMetadata, AiStatusMessage, AiTranscribeAndAskResponse, AllAiAgentChatOptions, GuardrailsOptions, UpsertAgentRequest } from '../../../internal-common/src/public-types/ai-agent.public-types';
3
+ import { AiChatModelName } from '../../../internal-common/src/public-types/ai-common.public-types';
4
+ import { JobId } from '../../../internal-common/src/public-types/job.public-types';
5
+ import { Paths } from '../../../internal-common/src/public-types/typescript.public-types';
6
+ import { AiAskOptions, AiAskOptionsWithVoice, AiChatOptionsWithoutVoice, AskResponse, AskWithVoiceResponse, TranscribeAndAskWithVoiceResponse, TranscribeAndChatResponse } from './ai-agent-client.types';
7
+ /**
8
+ * Parameters for creating or updating an AI agent.
9
+ * Excludes the `id` field, as it is derived from the agent instance.
10
+ * @category AI
11
+ */
12
+ export type UpsertAgentRequestParams = Omit<UpsertAgentRequest, 'id'>;
13
+ /**
14
+ * AiAgentReference provides methods for managing AI agents, including
15
+ * retrieving, updating, and deleting agents, handling agent contexts,
16
+ * and interacting with chat or voice-based AI functionalities.
17
+ * @category AI
18
+ */
19
+ export declare class AiAgentReference {
20
+ private readonly agentId;
21
+ private readonly agentApiKey;
22
+ private readonly ongoingChatSequences;
23
+ private readonly rpcManager;
24
+ private readonly socketManager;
25
+ private readonly jobClient;
26
+ private readonly backendFunctionManager;
27
+ /**
28
+ * Retrieves metadata and configuration of the AI agent.
29
+ */
30
+ get(): Promise<AiAgent | undefined>;
31
+ /**
32
+ * Creates or updates the AI agent with the provided parameters.
33
+ */
34
+ upsert(agent: UpsertAgentRequestParams): Promise<void>;
35
+ /**
36
+ * Deletes the AI agent.
37
+ */
38
+ delete(): Promise<void>;
39
+ /**
40
+ * Updates the agent's instruction prompt.
41
+ */
42
+ updateInstructions(instructions: string): Promise<void>;
43
+ /**
44
+ * Changes the AI model used by the agent.
45
+ */
46
+ updateModel(model: AiChatModelSelection): Promise<void>;
47
+ /**
48
+ * Updates the list of agents connected to this agent.
49
+ */
50
+ updateConnectedAgents(connectedAgents: Array<AiConnectedAgentMetadata>): Promise<void>;
51
+ /**
52
+ * Updates the agent's guardrails with the provided options.
53
+ */
54
+ updateGuardrails(guardrails: GuardrailsOptions): Promise<void>;
55
+ /**
56
+ * Updates the agent's custom guardrails with the provided custom guardrail.
57
+ */
58
+ updateCustomGuardrails(customGuardrail: string): Promise<void>;
59
+ /**
60
+ * Deletes the custom guardrails for the agent.
61
+ */
62
+ deleteCustomGuardrail(): Promise<void>;
63
+ /**
64
+ * Regenerates the api key for the agent.
65
+ * Will throw an error if the agent does not exist.
66
+ *
67
+ * @returns the new api key
68
+ */
69
+ regenerateApiKey(): Promise<string>;
70
+ /**
71
+ * Fetches the default api key for the agent
72
+ * @returns the api key if one exists
73
+ */
74
+ getApiKey(): Promise<string | undefined>;
75
+ /**
76
+ * Sends a prompt to the agent and receives streamed text responses.
77
+ * @param prompt The text prompt to send to the agent.
78
+ * @param options Optional parameters for the AI ask request.
79
+ * @param jobId (Optional) A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
80
+ * `squid.jobs().getJob(jobId)` to track progress. Make sure each job ID is both unique and kept private—anyone who
81
+ * knows it can look up the job’s status.
82
+ */
83
+ chat<T extends AiChatModelName | undefined>(prompt: string, options?: AiChatOptionsWithoutVoice<T>, jobId?: JobId): Observable<string>;
84
+ /**
85
+ * Transcribes the given file and performs a chat interaction.
86
+ * @param fileToTranscribe The audio file to transcribe and send to the agent.
87
+ * @param options Optional parameters for the AI ask request.
88
+ * @param jobId (Optional) A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
89
+ * `squid.jobs().getJob(jobId)` to track progress. Make sure each job ID is both unique and kept private—anyone who
90
+ * knows it can look up the job’s status.
91
+ */
92
+ transcribeAndChat(fileToTranscribe: File, options?: AiChatOptionsWithoutVoice, jobId?: JobId): Promise<TranscribeAndChatResponse>;
93
+ /**
94
+ * Sends a prompt and returns a full string response.
95
+ * @param prompt The text prompt to send to the agent.
96
+ * @param options Optional parameters for the AI ask request.
97
+ * @param jobId (Optional) A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
98
+ * `squid.jobs().getJob(jobId)` to track progress. Make sure each job ID is both unique and kept private—anyone who
99
+ * knows it can look up the job’s status.
100
+ */
101
+ ask<T extends AiChatModelName | undefined = undefined>(prompt: string, options?: AiAskOptions<T>, jobId?: JobId): Promise<string>;
102
+ /**
103
+ * Sends a prompt and returns the string response and file annotations.
104
+ * @param prompt The text prompt to send to the agent.
105
+ * @param options Optional parameters for the AI ask request.
106
+ * @param jobId (Optional) A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
107
+ * `squid.jobs().getJob(jobId)` to track progress. Make sure each job ID is both unique and kept private—anyone who
108
+ * knows it can look up the job’s status.
109
+ */
110
+ askWithAnnotations<T extends AiChatModelName | undefined = undefined>(prompt: string, options?: AiAskOptions<T>, jobId?: JobId): Promise<AskResponse>;
111
+ /**
112
+ * Sends a prompt and not wait for the result - the result can be tracked using the job ID
113
+ * (`squid.jobs().awaitJob(jobId)` or `squid.jobs().getJob(jobId)).
114
+ * The result is of type AiAskResponse which contains the response string and optional annotations.
115
+ * @param prompt The text prompt to send to the agent.
116
+ * @param jobId A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
117
+ * `squid.jobs().getJob(jobId)`
118
+ to track progress. Make sure each job ID is both unique and kept private—anyone who knows it can look up the job’s status.
119
+ * @param options Optional parameters for the AI ask request.
120
+ */
121
+ askAsync<T extends AiChatModelName | undefined = undefined>(prompt: string, jobId: JobId, options?: AiAskOptions<T>): Promise<void>;
122
+ /**
123
+ * Observes live status messages from the agent.
124
+ */
125
+ observeStatusUpdates(): Observable<AiStatusMessage>;
126
+ /**
127
+ * Returns a list of all chat history messages with the given 'memoryId'.
128
+ * Includes both user and & AI messages.
129
+ */
130
+ getChatHistory(memoryId: string): Promise<Array<AiChatMessage>>;
131
+ /**
132
+ * Transcribes audio and sends it to the agent for response.
133
+ * @param fileToTranscribe The audio file to transcribe and send to the agent.
134
+ * @param options Optional parameters for the AI ask request.
135
+ * @param jobId (Optional) A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
136
+ * `squid.jobs().getJob(jobId)` to track progress. Make sure each job ID is both unique and kept private—anyone who
137
+ * knows it can look up the job’s status.
138
+ */
139
+ transcribeAndAsk<T extends AiChatModelName | undefined>(fileToTranscribe: File, options?: AiAskOptions<T>, jobId?: JobId): Promise<AiTranscribeAndAskResponse>;
140
+ /**
141
+ * Transcribes audio and gets both text and voice response from the agent.
142
+ * @param fileToTranscribe The audio file to transcribe and send to the agent.
143
+ * @param options Optional parameters for the AI ask request.
144
+ * @param jobId (Optional) A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
145
+ * `squid.jobs().getJob(jobId)` to track progress. Make sure each job ID is both unique and kept private—anyone who
146
+ * knows it can look up the job’s status.
147
+ */
148
+ transcribeAndAskWithVoiceResponse<T extends AiChatModelName | undefined>(fileToTranscribe: File, options?: AiAskOptionsWithVoice<T>, jobId?: JobId): Promise<TranscribeAndAskWithVoiceResponse>;
149
+ /**
150
+ * Sends a prompt and gets both text and voice response from the agent.
151
+ * @param prompt The text prompt to send to the agent.
152
+ * @param options Optional parameters for the AI ask request.
153
+ * @param jobId (Optional) A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
154
+ * `squid.jobs().getJob(jobId)` to track progress. Make sure each job ID is both unique and kept private—anyone who
155
+ * knows it can look up the job’s status.
156
+ */
157
+ askWithVoiceResponse<T extends AiChatModelName | undefined>(prompt: string, options?: AiAskOptionsWithVoice<T>, jobId?: JobId): Promise<AskWithVoiceResponse>;
158
+ /**
159
+ * Sets a value at a specific path within the agent's options.
160
+ */
161
+ setAgentOptionInPath(path: Paths<AllAiAgentChatOptions> | string, value: unknown): Promise<void>;
162
+ /**
163
+ * Submits a feedback string for the agent. Requires an API Key.
164
+ * This feedback may update the agent's instructions, connected integrations, and may be forwarded to connected agents.
165
+ * @param feedback The feedback to provide for the agent.
166
+ */
167
+ provideFeedback(feedback: string): Promise<string>;
168
+ /**
169
+ * Helper to replace ${id:fileId} tags in the AI output with their corresponding Markdown.
170
+ * @param aiResponse
171
+ * @param annotations
172
+ * @private
173
+ */
174
+ private replaceFileTags;
175
+ private askInternal;
176
+ private chatInternal;
177
+ /**
178
+ * Calls rpcManager post but with the agent api key if one was given during construction
179
+ */
180
+ private post;
181
+ }
@@ -0,0 +1,37 @@
1
+ import { AiAgent, AiAgentId } from '../public-types';
2
+ import { AiAgentReference } from './ai-agent-client-reference';
3
+ /**
4
+ * Allows the user to provide custom options to the agent client
5
+ *
6
+ * @category AI
7
+ */
8
+ export type AiAgentClientOptions = {
9
+ /**
10
+ * Allows providing an agent API key that can be used instead of the app API key
11
+ */
12
+ apiKey?: string;
13
+ };
14
+ /**
15
+ * AiAgentClient manages AI agent interactions, including listing agents,
16
+ * handling real-time chat responses, and processing AI status updates
17
+ * through WebSocket notifications.
18
+ * @category AI
19
+ */
20
+ export declare class AiAgentClient {
21
+ private readonly rpcManager;
22
+ private readonly socketManager;
23
+ private readonly jobClient;
24
+ private readonly backendFunctionManager;
25
+ private readonly ongoingChatSequences;
26
+ /**
27
+ * Retrieves an instance of AiAgentReference for a specific agent ID.
28
+ * This reference provides methods for interacting with the agent.
29
+ */
30
+ agent(id: AiAgentId, options?: AiAgentClientOptions | undefined): AiAgentReference;
31
+ /**
32
+ * Lists all agents available in the system.
33
+ * @returns A promise that resolves to an array of AiAgent instances.
34
+ */
35
+ listAgents(): Promise<Array<AiAgent>>;
36
+ private handleChatResponse;
37
+ }
@@ -0,0 +1,69 @@
1
+ import { Observable } from 'rxjs';
2
+ import { AiAnnotation, AiChatOptions } from '../../../internal-common/src/public-types/ai-agent.public-types';
3
+ import { AiChatModelName } from '../../../internal-common/src/public-types/ai-common.public-types';
4
+ /**
5
+ * Response format for transcribing audio and generating a chat response.
6
+ * Contains the transcribed text and a stream of AI-generated responses.
7
+ * @category AI
8
+ */
9
+ export interface TranscribeAndChatResponse {
10
+ /** Transcribed text from the audio input. */
11
+ transcribedPrompt: string;
12
+ /** Stream of AI-generated responses. */
13
+ responseStream: Observable<string>;
14
+ }
15
+ /**
16
+ * Response format for transcribing audio and generating a text and voice response.
17
+ * Includes the transcribed prompt, the AI-generated response as text, and an audio file.
18
+ * @category AI
19
+ */
20
+ export interface TranscribeAndAskWithVoiceResponse {
21
+ /** Transcribed text from the audio input. */
22
+ transcribedPrompt: string;
23
+ /** AI-generated response as a string. */
24
+ responseString: string;
25
+ /** AI-generated voice response as an audio file. */
26
+ voiceResponseFile: File;
27
+ }
28
+ /**
29
+ * Response from an AI agent when asked a question or given a task.
30
+ * @category AI
31
+ */
32
+ export interface AskResponse {
33
+ /** The main text response from the AI agent. */
34
+ responseString: string;
35
+ /** Optional annotations that provide additional context or metadata about the response. */
36
+ annotations?: Record<string, AiAnnotation>;
37
+ }
38
+ /**
39
+ * Response format for AI-generated voice responses.
40
+ * Contains the AI-generated text response and the corresponding audio file.
41
+ * @category AI
42
+ */
43
+ export interface AskWithVoiceResponse {
44
+ /** AI-generated response as a string. */
45
+ responseString: string;
46
+ /** AI-generated voice response as an audio file. */
47
+ voiceResponseFile: File;
48
+ }
49
+ /**
50
+ * Chat options that exclude voice-specific configurations.
51
+ * @category AI
52
+ */
53
+ export type AiChatOptionsWithoutVoice<T extends AiChatModelName | undefined = undefined> = Omit<AiChatOptions<T>, 'voiceOptions'> & {
54
+ model?: T;
55
+ };
56
+ /**
57
+ * Options for AI-generated responses that exclude voice-specific settings and smooth typing behavior.
58
+ * @category AI
59
+ */
60
+ export type AiAskOptions<T extends AiChatModelName | undefined = undefined> = Omit<AiChatOptions<T>, 'voiceOptions' | 'smoothTyping'> & {
61
+ model?: T;
62
+ };
63
+ /**
64
+ * Options for AI-generated responses that include voice-specific settings but excludes smooth typing.
65
+ * @category AI
66
+ */
67
+ export type AiAskOptionsWithVoice<T extends AiChatModelName | undefined = undefined> = Omit<AiChatOptions<T>, 'smoothTyping'> & {
68
+ model?: T;
69
+ };
@@ -1,73 +1,72 @@
1
- import { RpcManager } from './rpc.manager';
2
- import { AssistantToolType, FunctionName } from '@squidcloud/common';
3
- import { BlobAndFilename } from './types';
4
- /**
5
- * Client class for interacting with an AI Assistant server.
6
- * Provides functionalities like creating and deleting assistants and threads,
7
- * querying assistants, and managing files associated with assistants and threads.
8
- */
9
- export declare class AiAssistantClient {
10
- private readonly rpcManager;
11
- constructor(rpcManager: RpcManager);
12
- /**
13
- * Creates a new AI assistant with specified characteristics.
14
- * @param name - The name of the assistant.
15
- * @param instructions - Instructions for the assistant.
16
- * @param functions - Array of function names annotated with "@aiFunction" in your Squid backend that will be
17
- * available tol the assistant.
18
- * @param toolTypes - Optional array of tool types. If you want to use files for retrieval, you must add them using
19
- * the addFileToAssistant method.
20
- * @returns A promise that resolves to the created assistant's ID.
21
- */
22
- createAssistant(name: string, instructions: string, functions: Array<FunctionName>, toolTypes?: Array<AssistantToolType>): Promise<string>;
23
- /**
24
- * Deletes an AI assistant.
25
- * @param assistantId - The ID of the assistant to be deleted.
26
- * @returns A promise that resolves when the assistant is deleted.
27
- */
28
- deleteAssistant(assistantId: string): Promise<void>;
29
- /**
30
- * Creates a new thread for an AI assistant. A thread is a long-lived conversation with the assistant that you can
31
- * always send questions to.
32
- * @param assistantId - The ID of the assistant for which the thread is created.
33
- * @returns A promise that resolves to the created thread's ID.
34
- */
35
- createThread(assistantId: string): Promise<string>;
36
- /**
37
- * Deletes a thread of an AI assistant.
38
- * @param threadId - The ID of the thread to be deleted.
39
- * @returns A promise that resolves when the thread is deleted.
40
- */
41
- deleteThread(threadId: string): Promise<void>;
42
- /**
43
- * Queries an AI assistant within a specific thread.
44
- * @param assistantId - The ID of the assistant.
45
- * @param threadId - The ID of the thread.
46
- * @param prompt - The query prompt.
47
- * @param fileIds - Optional array of file IDs to include in the query. These file IDs need to be added using the
48
- * addFileToThread method.
49
- * @returns A promise that resolves to the assistant's response.
50
- */
51
- queryAssistant(assistantId: string, threadId: string, prompt: string, fileIds?: string[]): Promise<string>;
52
- /**
53
- * Adds a file to an AI assistant that can be available for retrieval or code analyzer.
54
- * @param assistantId - The ID of the assistant.
55
- * @param file - The file or blob and filename to be added.
56
- * @returns A promise that resolves to the ID of the added file.
57
- */
58
- addFileToAssistant(assistantId: string, file: File | BlobAndFilename): Promise<string>;
59
- /**
60
- * Removes a file from an AI assistant.
61
- * @param assistantId - The ID of the assistant.
62
- * @param fileId - The ID of the file to be removed.
63
- * @returns A promise that resolves when the file is removed.
64
- */
65
- removeFileFromAssistant(assistantId: string, fileId: string): Promise<void>;
66
- /**
67
- * Adds a file to a specific thread of an AI assistant. These files can be used when asking a question in the thread.
68
- * @param threadId - The ID of the thread.
69
- * @param file - The file or blob and filename to be added.
70
- * @returns A promise that resolves to the ID of the added file.
71
- */
72
- addFileToThread(threadId: string, file: File | BlobAndFilename): Promise<string>;
73
- }
1
+ import { AssistantToolType, QueryAssistantOptions } from './public-types';
2
+ /**
3
+ * Client class for interacting with an AI Assistant server.
4
+ * Provides functionalities like creating and deleting assistants and threads,
5
+ * querying assistants, and managing files associated with assistants and threads.
6
+ * @category AI
7
+ */
8
+ export declare class AiAssistantClient {
9
+ private readonly rpcManager;
10
+ /**
11
+ * Creates a new AI assistant with specified characteristics.
12
+ * @param name - The name of the assistant.
13
+ * @param instructions - Instructions for the assistant.
14
+ * @param functions - Array of function names annotated with "@aiFunction" in your Squid backend that will be
15
+ * available to the assistant.
16
+ * @param toolTypes - Optional array of tool types. If you want to use files for retrieval, you must add them using
17
+ * the addFileToAssistant method.
18
+ * @returns A promise that resolves to the created assistant's ID.
19
+ */
20
+ createAssistant(name: string, instructions: string, functions: Array<string>, toolTypes?: Array<AssistantToolType>): Promise<string>;
21
+ /**
22
+ * Deletes an AI assistant.
23
+ * @param assistantId - The ID of the assistant to be deleted.
24
+ * @returns A promise that resolves when the assistant is deleted.
25
+ */
26
+ deleteAssistant(assistantId: string): Promise<void>;
27
+ /**
28
+ * Creates a new thread for an AI assistant. A thread is a long-lived conversation with the assistant that you can
29
+ * always send questions to.
30
+ * @param assistantId - The ID of the assistant for which the thread is created.
31
+ * @returns A promise that resolves to the created thread's ID.
32
+ */
33
+ createThread(assistantId: string): Promise<string>;
34
+ /**
35
+ * Deletes a thread of an AI assistant.
36
+ * @param threadId - The ID of the thread to be deleted.
37
+ * @returns A promise that resolves when the thread is deleted.
38
+ */
39
+ deleteThread(threadId: string): Promise<void>;
40
+ /**
41
+ * Queries an AI assistant within a specific thread.
42
+ * @param assistantId - The ID of the assistant.
43
+ * @param threadId - The ID of the thread.
44
+ * @param prompt - The query prompt.
45
+ * @param fileIds - Optional array of file IDs to include in the query. These file IDs need to be added using the
46
+ * addFileToThread method.
47
+ * @param options - Optional query options.
48
+ * @returns A promise that resolves to the assistant's response.
49
+ */
50
+ queryAssistant(assistantId: string, threadId: string, prompt: string, fileIds?: string[], options?: QueryAssistantOptions): Promise<string>;
51
+ /**
52
+ * Adds a file to an AI assistant that can be available for retrieval or code analyzer.
53
+ * @param assistantId - The ID of the assistant.
54
+ * @param file - The file to be added.
55
+ * @returns A promise that resolves to the ID of the added file.
56
+ */
57
+ addFileToAssistant(assistantId: string, file: File): Promise<string>;
58
+ /**
59
+ * Removes a file from an AI assistant.
60
+ * @param assistantId - The ID of the assistant.
61
+ * @param fileId - The ID of the file to be removed.
62
+ * @returns A promise that resolves when the file is removed.
63
+ */
64
+ removeFileFromAssistant(assistantId: string, fileId: string): Promise<void>;
65
+ /**
66
+ * Adds a file to a specific thread of an AI assistant. These files can be used when asking a question in the thread.
67
+ * @param threadId - The ID of the thread.
68
+ * @param file - The file to be added.
69
+ * @returns A promise that resolves to the ID of the added file.
70
+ */
71
+ addFileToThread(threadId: string, file: File): Promise<string>;
72
+ }
@@ -0,0 +1,25 @@
1
+ import { AiAudioCreateSpeechOptions, AiAudioTranscribeOptions } from './public-types';
2
+ /**
3
+ * AiAudioClient provides methods for AI-driven audio processing,
4
+ * including speech transcription and text-to-speech synthesis.
5
+ * @category AI
6
+ */
7
+ export declare class AiAudioClient {
8
+ private readonly rpcManager;
9
+ /**
10
+ * Transcribes the spoken content of an audio file into text.
11
+ *
12
+ * @param file - The audio file to transcribe.
13
+ * @param options - Options specifying the transcription model and behavior.
14
+ * @returns A Promise that resolves to the transcribed text.
15
+ */
16
+ transcribe(file: File, options?: AiAudioTranscribeOptions): Promise<string>;
17
+ /**
18
+ * Converts a text input into a spoken audio file using AI-generated speech.
19
+ *
20
+ * @param input - The text to convert to speech.
21
+ * @param options - Options for customizing speech synthesis (e.g., voice, speed).
22
+ * @returns A Promise that resolves to an audio File containing the synthesized speech.
23
+ */
24
+ createSpeech(input: string, options: AiAudioCreateSpeechOptions): Promise<File>;
25
+ }
@@ -0,0 +1,129 @@
1
+ import { AiQueryOptions, AiQueryResponse, ExecuteAiApiResponse } from '../../internal-common/src/public-types/ai-query.public-types';
2
+ import { AiAgentClientOptions } from './agent/ai-agent-client';
3
+ import { AiAgentReference } from './agent/ai-agent-client-reference';
4
+ import { AiAssistantClient } from './ai-assistant-client';
5
+ import { AiAudioClient } from './ai-audio-client';
6
+ import { AiFilesClient } from './ai-files-client';
7
+ import { AiImageClient } from './ai-image-client';
8
+ import { AiKnowledgeBaseReference } from './ai-knowledge-base/ai-knowledge-base-client-reference';
9
+ import { AiMatchMakingClient } from './ai-matchmaking-client';
10
+ import { AiAgent, AiAgentApiIntegrationOptions, AiAgentId, AiFileProviderType, AiKnowledgeBase, AiKnowledgeBaseId, AiProviderType, AiSessionContext, ApplicationAiSettings, IntegrationId, SecretKey } from './public-types';
11
+ /**
12
+ * AiClient class serves as a facade for interacting with different AI services.
13
+ * It provides simplified access to AI chatbot and assistant functionalities
14
+ * through its methods.
15
+ * @category AI
16
+ */
17
+ export declare class AiClient {
18
+ private readonly socketManager;
19
+ private readonly rpcManager;
20
+ private readonly jobClient;
21
+ private readonly backendFunctionManager;
22
+ private readonly aiAssistantClient;
23
+ private aiAgentClient?;
24
+ private aiKnowledgeBaseClient?;
25
+ /**
26
+ * Returns a reference to the specified AI agent.
27
+ * If no ID is provided, the built-in agent is used by default.
28
+ */
29
+ agent(agentId?: AiAgentId, options?: AiAgentClientOptions | undefined): AiAgentReference;
30
+ /**
31
+ * Returns a reference to the specified AI knowledge base.
32
+ */
33
+ knowledgeBase(knowledgeBaseId: AiKnowledgeBaseId): AiKnowledgeBaseReference;
34
+ /**
35
+ * Lists all available AI agents.
36
+ */
37
+ listAgents(): Promise<Array<AiAgent>>;
38
+ /**
39
+ * Lists all available AI agents.
40
+ */
41
+ listKnowledgeBases(): Promise<Array<AiKnowledgeBase>>;
42
+ /**
43
+ * Retrieves the AI assistant client.
44
+ * @returns An instance of AiAssistantClient.
45
+ */
46
+ assistant(): AiAssistantClient;
47
+ /**
48
+ * Retrieves an AI image client.
49
+ */
50
+ image(): AiImageClient;
51
+ /**
52
+ * Retrieves an AI audio client.
53
+ */
54
+ audio(): AiAudioClient;
55
+ /**
56
+ * Retrieves an AI match-making client.
57
+ * @deprecated - Use `knowledgebase('kbId').searchContextsWith*()` instead.
58
+ */
59
+ matchMaking(): AiMatchMakingClient;
60
+ /**
61
+ * Creates a client to manage files for a specific AI provider.
62
+ *
63
+ * @param provider - The AI provider (openai, gemini, or anthropic).
64
+ * @returns An AiFilesClient bound to the specified provider.
65
+ * @example
66
+ * ```typescript
67
+ * const openaiFiles = squid.ai().files('openai');
68
+ * const fileId = await openaiFiles.uploadFile({ file });
69
+ * await openaiFiles.deleteFile(fileId);
70
+ * ```
71
+ */
72
+ files(provider: AiFileProviderType): AiFilesClient;
73
+ /**
74
+ * Executes an AI query using a specific DB integration, sending a prompt to the AI and returning its response.
75
+ * This function allows for direct interaction with the AI's capabilities by sending text prompts and receiving
76
+ * the AI's responses, which can be used for various applications such as automating tasks, generating content,
77
+ * or obtaining information.
78
+ *
79
+ * @param integrationId The identifier for the DB integration which is used to direct the query to the
80
+ * appropriate DB.
81
+ * @param prompt The text prompt to send to the AI. This should be formulated in a way that the AI can
82
+ * understand and respond to, taking into account the nature of the task or the information
83
+ * sought.
84
+ * @param options Additional options to customize the query execution.
85
+ * @returns A promise that resolves to an `ExecuteAiQueryResponse`. This response includes the AI's
86
+ * reply to the provided prompt, along with any other relevant information that is part of
87
+ * the AI's response. The promise can be awaited to handle the response asynchronously.
88
+ *
89
+ * @example
90
+ * ```
91
+ * const response = await squid.ai().executeAiQuery(myDbIntegrationId, "How many transactions ran yesterday?");
92
+ * console.log(response);
93
+ * ```
94
+ *
95
+ * Can be used with an API key or using a security rule with @secureAiQuery() decorator.
96
+ *
97
+ * For more details on the usage and capabilities of the AI Assistant, refer to the documentation provided at
98
+ * {@link https://docs.squid.cloud/docs/ai}.
99
+ */
100
+ executeAiQuery(integrationId: IntegrationId, prompt: string, options?: AiQueryOptions): Promise<AiQueryResponse>;
101
+ /**
102
+ * Executes an AI-powered API call using a specific integration.
103
+ * The AI will select appropriate endpoints, generate request bodies,
104
+ * and analyze responses to answer the provided prompt.
105
+ *
106
+ * @param integrationId - The API integration to use
107
+ * @param prompt - Natural language description of what to accomplish
108
+ * @param options - Optional configuration including allowed endpoints and verbose updates
109
+ * @param sessionContext - Optional session context for audit trails and tracing
110
+ * @returns Promise resolving to the API call result with answer and execution details
111
+ */
112
+ executeAiApiCall(integrationId: IntegrationId, prompt: string, options?: AiAgentApiIntegrationOptions, sessionContext?: AiSessionContext): Promise<ExecuteAiApiResponse>;
113
+ /**
114
+ * Returns name of the secret that stores API key for the given AI provider type.
115
+ * This API key is used for all requests to the AI provider done from the application.
116
+ */
117
+ getApplicationAiSettings(): Promise<ApplicationAiSettings>;
118
+ /** Sets new application AI settings. Overwrites the existing value. */
119
+ setApplicationAiSettings(settings: ApplicationAiSettings): Promise<void>;
120
+ /**
121
+ * Sets the name of the secret that stores API key for the given AI provider type.
122
+ * This API key is used for all requests to the AI provider done from the application.
123
+ * To delete the existing secret key use 'undefined' for the name of the secret.
124
+ * Returns the updated state of the AI application settings.
125
+ */
126
+ setAiProviderApiKeySecret(providerType: AiProviderType, secretKey: SecretKey | undefined): Promise<ApplicationAiSettings>;
127
+ private getAiAgentClient;
128
+ private getAiKnowledgeBaseClient;
129
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Options for uploading a file to an AI provider.
3
+ * @category AI
4
+ */
5
+ export interface UploadAiFileOptions {
6
+ /** The file to upload. */
7
+ file: File;
8
+ /** Optional expiration time in seconds for automatic cleanup. */
9
+ expirationInSeconds?: number;
10
+ }
11
+ /**
12
+ * AiFilesClient provides methods for managing files with a specific AI provider.
13
+ * The provider is bound when the client is created via `squid.ai().files(provider)`.
14
+ * @category AI
15
+ */
16
+ export declare class AiFilesClient {
17
+ private readonly provider;
18
+ private readonly rpcManager;
19
+ /**
20
+ * Uploads a file to the AI provider for use with AI features like code interpreter.
21
+ *
22
+ * @param options - Options for uploading the file.
23
+ * @returns A Promise that resolves to the file ID assigned by the provider.
24
+ */
25
+ uploadFile(options: UploadAiFileOptions): Promise<string>;
26
+ /**
27
+ * Deletes a file from the AI provider's storage.
28
+ *
29
+ * @param fileId - The ID of the file to delete.
30
+ * @returns A Promise that resolves to true if the file was deleted, false if it didn't exist.
31
+ */
32
+ deleteFile(fileId: string): Promise<boolean>;
33
+ }