@squidcloud/client 1.0.369 → 1.0.371

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.
@@ -546,20 +546,6 @@ export interface AnthropicChatOptions extends BaseAiChatOptions {
546
546
  /** The level of reasoning effort to apply. Defaults to no reasoning. */
547
547
  reasoningEffort?: AiReasoningEffort;
548
548
  }
549
- /**
550
- * Optional settings for an AI session, allowing partial specification of identifiers.
551
- * @category AI
552
- */
553
- export type AiSessionOptions = Partial<{
554
- /** A unique identifier for tracing the session, if provided. */
555
- traceId: string;
556
- /** The ID of the client initiating the session, if specified. */
557
- clientId: string;
558
- /** The ID of the AI agent involved in the session, if specified. */
559
- agentId: string;
560
- /** The ID of the AI agent involved in starting the session, if specified. */
561
- rootAgentId: string;
562
- }>;
563
549
  /**
564
550
  * The generic options type. When no generic is provided,
565
551
  * the type is inferred from the provided overrideModel (or falls back to BaseAiAgentChatOptions).
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Represents a unique identifier for a job.
3
+ */
4
+ export type JobId = string;
5
+ /** Represents a request to get an asynchronous job by its ID. */
6
+ export interface GetJobRequest {
7
+ /** The unique identifier of the job to retrieve */
8
+ jobId: JobId;
9
+ }
10
+ /**
11
+ * Represents a request to get an asynchronous job by its ID.
12
+ */
13
+ export interface GetJobResponse {
14
+ /** The job details */
15
+ job: AsyncJob | undefined;
16
+ }
17
+ /**
18
+ * Represents a request to subscribe to job updates.
19
+ * This allows clients to receive real-time updates about the job's status.
20
+ */
21
+ export interface SubscribeToJobRequest {
22
+ /** The unique identifier of the job to subscribe to */
23
+ jobId: JobId;
24
+ }
25
+ /**
26
+ * Represents an asynchronous job
27
+ */
28
+ export interface AsyncJob<T = any> {
29
+ /**
30
+ * The unique identifier of the job.
31
+ */
32
+ id: JobId;
33
+ /**
34
+ * The timestamp when the job was created.
35
+ */
36
+ createdAt: Date;
37
+ /**
38
+ * The timestamp when the job was last updated.
39
+ */
40
+ updatedAt: Date;
41
+ /**
42
+ * The current status of the job.
43
+ * Can be one of the following:
44
+ * - 'in_progress': The job is currently being processed.
45
+ * - 'completed': The job has finished successfully.
46
+ * - 'failed': The job has failed.
47
+ */
48
+ status: 'in_progress' | 'completed' | 'failed';
49
+ /**
50
+ * The result of the job, if available.
51
+ * This is of type `T` and is optional.
52
+ */
53
+ result?: T;
54
+ /**
55
+ * The error message, if the job has failed.
56
+ * This is optional.
57
+ */
58
+ error?: string;
59
+ }
@@ -1,6 +1,7 @@
1
1
  import { AgentContextRequest, AiAgent, AiAgentContext, AiAudioCreateSpeechOptions, AiChatModelName, AiChatOptions, AiContextMetadata, AiContextMetadataFilter, AiEmbeddingsModelName, AiGenerateImageOptions, AiProviderType, AiSearchOptions, AiSearchResultChunk, AllAiAgentChatOptions, ApplicationAiSettings } from '../public-types/ai-agent.public-types';
2
2
  import { AiFunctionId } from '../public-types/backend.public-types';
3
3
  import { AiAgentId, AppId, ClientRequestId } from '../public-types/communication.public-types';
4
+ import { JobId } from '../public-types/job.public-types';
4
5
  import { SecretKey } from '../public-types/secret.public-types';
5
6
  export type ModelDataType = {
6
7
  maxTokens: number;
@@ -12,11 +13,13 @@ export interface AiChatRequest {
12
13
  clientRequestId: ClientRequestId;
13
14
  prompt?: string;
14
15
  options?: AllAiAgentChatOptions;
16
+ jobId: JobId;
15
17
  }
16
18
  export interface AiAskRequest {
17
19
  agentId: AiAgentId;
18
20
  prompt?: string;
19
21
  options?: AllAiAgentChatOptions;
22
+ jobId: JobId;
20
23
  }
21
24
  export interface AiGenerateImageRequest {
22
25
  prompt: string;
@@ -1,5 +1,6 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { AgentContextRequest, AiAgent, AiAgentContext, AiChatModelName, AiConnectedAgentMetadata, AiObserveStatusOptions, AiSearchOptions, AiSearchResultChunk, AiStatusMessage, AiTranscribeAndAskResponse, GuardrailsOptions, UpsertAgentRequest } from '../../../internal-common/src/public-types/ai-agent.public-types';
3
+ import { JobId } from '../../../internal-common/src/public-types/job.public-types';
3
4
  import { AiAskOptions, AiAskOptionsWithVoice, AiChatOptionsWithoutVoice, AskWithVoiceResponse, TranscribeAndAskWithVoiceResponse, TranscribeAndChatResponse } from './ai-agent-client.types';
4
5
  /**
5
6
  * Parameters for creating or updating an AI agent.
@@ -19,6 +20,7 @@ export declare class AiAgentReference {
19
20
  private readonly statusUpdates;
20
21
  private readonly rpcManager;
21
22
  private readonly socketManager;
23
+ private readonly jobClient;
22
24
  /**
23
25
  * Retrieves metadata and configuration of the AI agent.
24
26
  */
@@ -89,36 +91,76 @@ export declare class AiAgentReference {
89
91
  deleteCustomGuardrail(): Promise<void>;
90
92
  /**
91
93
  * Sends a prompt to the agent and receives streamed text responses.
94
+ * @param prompt The text prompt to send to the agent.
95
+ * @param options Optional parameters for the AI ask request.
96
+ * @param jobId (Optional) A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
97
+ * `squid.jobs().getJob(jobId)` to track progress. Make sure each job ID is both unique and kept private—anyone who
98
+ * knows it can look up the job’s status.
92
99
  */
93
- chat<T extends AiChatModelName | undefined>(prompt: string, options?: AiChatOptionsWithoutVoice<T>): Observable<string>;
100
+ chat<T extends AiChatModelName | undefined>(prompt: string, options?: AiChatOptionsWithoutVoice<T>, jobId?: JobId): Observable<string>;
94
101
  /**
95
102
  * Transcribes the given file and performs a chat interaction.
103
+ * @param fileToTranscribe The audio file to transcribe and send to the agent.
104
+ * @param options Optional parameters for the AI ask request.
105
+ * @param jobId (Optional) A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
106
+ * `squid.jobs().getJob(jobId)` to track progress. Make sure each job ID is both unique and kept private—anyone who
107
+ * knows it can look up the job’s status.
96
108
  */
97
- transcribeAndChat(fileToTranscribe: File, options?: AiChatOptionsWithoutVoice): Promise<TranscribeAndChatResponse>;
109
+ transcribeAndChat(fileToTranscribe: File, options?: AiChatOptionsWithoutVoice, jobId?: JobId): Promise<TranscribeAndChatResponse>;
98
110
  /**
99
111
  * Performs a semantic search using the agent's knowledge base.
100
112
  */
101
113
  search(options: AiSearchOptions): Promise<Array<AiSearchResultChunk>>;
102
114
  /**
103
115
  * Sends a prompt and receives a full string response.
116
+ * @param prompt The text prompt to send to the agent.
117
+ * @param options Optional parameters for the AI ask request.
118
+ * @param jobId (Optional) A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
119
+ * `squid.jobs().getJob(jobId)` to track progress. Make sure each job ID is both unique and kept private—anyone who
120
+ * knows it can look up the job’s status.
104
121
  */
105
- ask<T extends AiChatModelName | undefined = undefined>(prompt: string, options?: AiAskOptions<T>): Promise<string>;
122
+ ask<T extends AiChatModelName | undefined = undefined>(prompt: string, options?: AiAskOptions<T>, jobId?: JobId): Promise<string>;
123
+ /**
124
+ * Sends a prompt and not wait for the result - the result can be tracked using the job ID
125
+ * (`squid.jobs().awaitJob(jobId)` or `squid.jobs().getJob(jobId)).
126
+ * @param prompt The text prompt to send to the agent.
127
+ * @param jobId A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
128
+ * `squid.jobs().getJob(jobId)`
129
+ 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.
130
+ * @param options Optional parameters for the AI ask request.
131
+ */
132
+ askAsync<T extends AiChatModelName | undefined = undefined>(prompt: string, jobId: JobId, options?: AiAskOptions<T>): Promise<void>;
106
133
  /**
107
134
  * Observes live status messages from the agent.
108
135
  */
109
136
  observeStatusUpdates(options?: AiObserveStatusOptions): Observable<AiStatusMessage>;
110
137
  /**
111
138
  * Transcribes audio and sends it to the agent for response.
139
+ * @param fileToTranscribe The audio file to transcribe and send to the agent.
140
+ * @param options Optional parameters for the AI ask request.
141
+ * @param jobId (Optional) A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
142
+ * `squid.jobs().getJob(jobId)` to track progress. Make sure each job ID is both unique and kept private—anyone who
143
+ * knows it can look up the job’s status.
112
144
  */
113
- transcribeAndAsk<T extends AiChatModelName | undefined>(fileToTranscribe: File, options?: AiAskOptions<T>): Promise<AiTranscribeAndAskResponse>;
145
+ transcribeAndAsk<T extends AiChatModelName | undefined>(fileToTranscribe: File, options?: AiAskOptions<T>, jobId?: JobId): Promise<AiTranscribeAndAskResponse>;
114
146
  /**
115
147
  * Transcribes audio and gets both text and voice response from the agent.
148
+ * @param fileToTranscribe The audio file to transcribe and send to the agent.
149
+ * @param options Optional parameters for the AI ask request.
150
+ * @param jobId (Optional) A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
151
+ * `squid.jobs().getJob(jobId)` to track progress. Make sure each job ID is both unique and kept private—anyone who
152
+ * knows it can look up the job’s status.
116
153
  */
117
- transcribeAndAskWithVoiceResponse<T extends AiChatModelName | undefined>(fileToTranscribe: File, options?: AiAskOptionsWithVoice<T>): Promise<TranscribeAndAskWithVoiceResponse>;
154
+ transcribeAndAskWithVoiceResponse<T extends AiChatModelName | undefined>(fileToTranscribe: File, options?: AiAskOptionsWithVoice<T>, jobId?: JobId): Promise<TranscribeAndAskWithVoiceResponse>;
118
155
  /**
119
156
  * Sends a prompt and gets both text and voice response from the agent.
157
+ * @param prompt The text prompt to send to the agent.
158
+ * @param options Optional parameters for the AI ask request.
159
+ * @param jobId (Optional) A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
160
+ * `squid.jobs().getJob(jobId)` to track progress. Make sure each job ID is both unique and kept private—anyone who
161
+ * knows it can look up the job’s status.
120
162
  */
121
- askWithVoiceResponse<T extends AiChatModelName | undefined>(prompt: string, options?: AiAskOptionsWithVoice<T>): Promise<AskWithVoiceResponse>;
163
+ askWithVoiceResponse<T extends AiChatModelName | undefined>(prompt: string, options?: AiAskOptionsWithVoice<T>, jobId?: JobId): Promise<AskWithVoiceResponse>;
122
164
  private askInternal;
123
165
  private createStatusSubject;
124
166
  private chatInternal;
@@ -9,6 +9,7 @@ import { AiAgentReference } from './ai-agent-client-reference';
9
9
  export declare class AiAgentClient {
10
10
  private readonly rpcManager;
11
11
  private readonly socketManager;
12
+ private readonly jobClient;
12
13
  private readonly ongoingChatSequences;
13
14
  private readonly statusUpdates;
14
15
  /**
@@ -14,6 +14,7 @@ import { AiAgent, AiAgentId, AiProviderType, ApplicationAiSettings, IntegrationI
14
14
  export declare class AiClient {
15
15
  private readonly socketManager;
16
16
  private readonly rpcManager;
17
+ private readonly jobClient;
17
18
  private readonly aiAssistantClient;
18
19
  private aiAgentClient?;
19
20
  /**
@@ -97,4 +98,5 @@ export declare class AiClient {
97
98
  * Returns the updated state of the AI application settings.
98
99
  */
99
100
  setAiProviderApiKeySecret(providerType: AiProviderType, secretKey: SecretKey | undefined): Promise<ApplicationAiSettings>;
101
+ private getAiAgentClient;
100
102
  }
@@ -27,6 +27,7 @@ export * from './execute-function-options';
27
27
  export * from './extraction-client';
28
28
  export * from './file-utils';
29
29
  export * from './integration-client';
30
+ export * from './job-client';
30
31
  export * from './mutation/mutation-sender';
31
32
  export * from './native-query-manager';
32
33
  export * from './observability-client';
@@ -0,0 +1,31 @@
1
+ import { AsyncJob, JobId } from '../../internal-common/src/public-types/job.public-types';
2
+ /**
3
+ * Handles job subscriptions and notifications.
4
+ *
5
+ * **Important:** Each `jobId` must be globally unique and kept private.
6
+ * Anyone who knows a job’s ID can query its status or result.
7
+ */
8
+ export declare class JobClient {
9
+ private readonly socketManager;
10
+ private readonly rpcManager;
11
+ private isListening;
12
+ private readonly listeners;
13
+ /**
14
+ * Retrieves the current status (and, if completed, the result) of a job.
15
+ *
16
+ * @param jobId A unique, private identifier for the job.
17
+ * Do **not** reuse a `jobId` across clients—possessing the ID
18
+ * allows anyone to inspect the job’s state.
19
+ */
20
+ getJob<T = any>(jobId: JobId): Promise<AsyncJob<T> | undefined>;
21
+ /**
22
+ * Waits until the specified job finishes, then resolves with its result or
23
+ * throws if the job fails.
24
+ *
25
+ * @param jobId A unique, private identifier for the job.
26
+ * Do **not** reuse a `jobId` across clients—possessing the ID
27
+ * allows anyone to inspect the job’s state.
28
+ */
29
+ awaitJob<T = any>(jobId: JobId): Promise<T>;
30
+ private maybeListenToJobs;
31
+ }
@@ -12,6 +12,7 @@ export * from '../../internal-common/src/public-types/document.public-types';
12
12
  export * from '../../internal-common/src/public-types/extraction.public-types';
13
13
  export * from '../../internal-common/src/public-types/http-status.public-types';
14
14
  export * from '../../internal-common/src/public-types/integration.public-types';
15
+ export * from '../../internal-common/src/public-types/job.public-types';
15
16
  export * from '../../internal-common/src/public-types/metric.public-types';
16
17
  export * from '../../internal-common/src/public-types/openapi.public-types';
17
18
  export * from '../../internal-common/src/public-types/query.public-types';
@@ -6,6 +6,7 @@ import { ConnectionDetails } from './connection-details';
6
6
  import { DistributedLock } from './distributed-lock.manager';
7
7
  import { ExecuteFunctionOptions } from './execute-function-options';
8
8
  import { ExtractionClient } from './extraction-client';
9
+ import { JobClient } from './job-client';
9
10
  import { ObservabilityClient } from './observability-client';
10
11
  import { PersonalStorageClient } from './personal-storage-client';
11
12
  import { ApiKey, AppId, CollectionName, DocumentData, EnvironmentId, IntegrationId, SquidDeveloperId, SquidRegion } from './public-types';
@@ -108,6 +109,7 @@ export declare class Squid {
108
109
  private readonly querySender;
109
110
  private static readonly squidInstancesMap;
110
111
  private readonly aiClient;
112
+ private readonly jobClient;
111
113
  private readonly apiClient;
112
114
  private readonly adminClient;
113
115
  private readonly webClient;
@@ -226,10 +228,12 @@ export declare class Squid {
226
228
  executeNativeElasticQuery<T = any>(integrationId: IntegrationId, index: string, body: Record<string, any>, endpoint?: string, method?: 'GET' | 'POST'): Promise<Array<T>>;
227
229
  /**
228
230
  * Returns a set of AI specific clients.
229
- *
230
- * @returns A set of AI specific clients.
231
231
  */
232
232
  ai(): AiClient;
233
+ /**
234
+ * Returns a set of functionality for interacting with jobs.
235
+ */
236
+ job(): JobClient;
233
237
  /**
234
238
  * Returns a set of functionality for interacting with API integrations.
235
239
  */
@@ -2,4 +2,4 @@
2
2
  * The current version of the SquidCloud client package.
3
3
  * @category Platform
4
4
  */
5
- export declare const SQUIDCLOUD_CLIENT_PACKAGE_VERSION = "1.0.369";
5
+ export declare const SQUIDCLOUD_CLIENT_PACKAGE_VERSION = "1.0.371";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.369",
3
+ "version": "1.0.371",
4
4
  "description": "A typescript implementation of the Squid client",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",