@squidcloud/client 1.0.391 → 1.0.392

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 (54) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/esm/index.js +1 -1
  3. package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +87 -38
  4. package/dist/internal-common/src/public-types/ai-common.public-types.d.ts +3 -16
  5. package/dist/internal-common/src/public-types/ai-knowledge-base.public-types.d.ts +51 -4
  6. package/dist/internal-common/src/public-types/ai-query.public-types.d.ts +56 -12
  7. package/dist/internal-common/src/public-types/api.public-types.d.ts +1 -10
  8. package/dist/internal-common/src/public-types/communication.public-types.d.ts +1 -1
  9. package/dist/internal-common/src/public-types/extraction.public-types.d.ts +12 -0
  10. package/dist/internal-common/src/public-types/integration.public-types.d.ts +1 -1
  11. package/dist/typescript-client/src/agent/ai-agent-client-reference.d.ts +14 -4
  12. package/dist/typescript-client/src/agent/ai-agent-client.types.d.ts +11 -1
  13. package/dist/typescript-client/src/ai-client.d.ts +10 -15
  14. package/dist/typescript-client/src/{ai-knowledge-base.reference.d.ts → ai-knowledge-base/ai-knowledge-base-client-reference.d.ts} +12 -4
  15. package/dist/typescript-client/src/ai-knowledge-base/ai-knowledge-base-client.d.ts +28 -0
  16. package/dist/typescript-client/src/index.d.ts +2 -1
  17. package/dist/typescript-client/src/version.d.ts +1 -1
  18. package/package.json +5 -5
  19. package/dist/internal-common/src/metric-name.d.ts +0 -9
  20. package/dist/internal-common/src/public-types-backend/api-call.public-context.d.ts +0 -30
  21. package/dist/internal-common/src/public-types-backend/mutation.public-context.d.ts +0 -148
  22. package/dist/internal-common/src/public-types-backend/native-query.public-context.d.ts +0 -60
  23. package/dist/internal-common/src/public-types-backend/query.public-context.d.ts +0 -166
  24. package/dist/internal-common/src/types/ai-agent.types.d.ts +0 -156
  25. package/dist/internal-common/src/types/ai-assistant.types.d.ts +0 -1
  26. package/dist/internal-common/src/types/ai-knowledge-base.types.d.ts +0 -115
  27. package/dist/internal-common/src/types/ai-matchmaking.types.d.ts +0 -59
  28. package/dist/internal-common/src/types/backend-function.types.d.ts +0 -1
  29. package/dist/internal-common/src/types/communication.types.d.ts +0 -1
  30. package/dist/internal-common/src/types/document.types.d.ts +0 -1
  31. package/dist/internal-common/src/types/file.types.d.ts +0 -6
  32. package/dist/internal-common/src/types/headers.types.d.ts +0 -17
  33. package/dist/internal-common/src/types/mutation.types.d.ts +0 -1
  34. package/dist/internal-common/src/types/notification.types.d.ts +0 -5
  35. package/dist/internal-common/src/types/observability.types.d.ts +0 -78
  36. package/dist/internal-common/src/types/query.types.d.ts +0 -13
  37. package/dist/internal-common/src/types/secret.types.d.ts +0 -2
  38. package/dist/internal-common/src/types/socket.types.d.ts +0 -1
  39. package/dist/internal-common/src/types/stage.d.ts +0 -9
  40. package/dist/internal-common/src/types/time-units.d.ts +0 -1
  41. package/dist/internal-common/src/types/url-shortener.types.d.ts +0 -41
  42. package/dist/internal-common/src/utils/array.d.ts +0 -7
  43. package/dist/internal-common/src/utils/e2e-test-utils.d.ts +0 -2
  44. package/dist/internal-common/src/utils/global.utils.d.ts +0 -1
  45. package/dist/internal-common/src/utils/http.d.ts +0 -5
  46. package/dist/internal-common/src/utils/lock.manager.d.ts +0 -14
  47. package/dist/internal-common/src/utils/metric-utils.d.ts +0 -4
  48. package/dist/internal-common/src/utils/metrics.types.d.ts +0 -7
  49. package/dist/internal-common/src/utils/object.d.ts +0 -58
  50. package/dist/internal-common/src/utils/serialization.d.ts +0 -11
  51. package/dist/internal-common/src/utils/squid.constants.d.ts +0 -1
  52. package/dist/internal-common/src/utils/trace-id-generator.d.ts +0 -1
  53. package/dist/internal-common/src/utils/validation.d.ts +0 -19
  54. package/dist/internal-common/src/websocket.impl.d.ts +0 -26
@@ -1,7 +1,8 @@
1
- import { AiAudioCreateSpeechModelName, AiAudioTranscriptionModelName, AiChatModelName, AiEmbeddingsModelName, AiImageModelName, AiProviderType, AiRerankProvider, AnthropicChatModelName, GeminiChatModelName, GrokChatModelName, OpenAiAudioCreateSpeechModelName, OpenAiAudioTranscriptionModelName, OpenAiChatModelName, OpenAiCreateSpeechFormat, OpenAiReasoningChatModelName } from './ai-common.public-types';
1
+ import { AiAudioCreateSpeechModelName, AiAudioTranscriptionModelName, AiChatModelName, AiEmbeddingsModelName, AiImageModelName, AiProviderType, AiRerankProvider, AnthropicChatModelName, GeminiChatModelName, GrokChatModelName, OpenAiAudioCreateSpeechModelName, OpenAiAudioTranscriptionModelName, OpenAiChatModelName, OpenAiCreateSpeechFormat } from './ai-common.public-types';
2
2
  import { AiContextMetadata, AiContextMetadataFilter, AiKnowledgeBaseContextType, AiRagType } from './ai-knowledge-base.public-types';
3
3
  import { AiFunctionId, AiFunctionIdWithContext, UserAiChatModelName } from './backend.public-types';
4
4
  import { AiAgentId, AiContextId, AiKnowledgeBaseId, IntegrationId } from './communication.public-types';
5
+ import { DocumentExtractionMethod } from './extraction.public-types';
5
6
  import { IntegrationType } from './integration.public-types';
6
7
  import { JobId } from './job.public-types';
7
8
  import { SecretKey } from './secret.public-types';
@@ -151,17 +152,27 @@ export type AiAgentResponseFormat = 'text' | 'json_object';
151
152
  /**
152
153
  * @category AI
153
154
  */
154
- export type AiFileUrlType = 'image';
155
+ export type AiFileUrlType = 'image' | 'document';
155
156
  /**
156
157
  * Represents a URL reference to an AI-processed file, such as an image.
157
158
  * @category AI
158
159
  */
159
160
  export interface AiFileUrl {
161
+ /** The unique identifier for the file URL for the current request. */
162
+ id: string;
160
163
  /** The type of file referenced by the URL (e.g., 'image'). */
161
164
  type: AiFileUrlType;
165
+ /** The purpose of the file, indicating how it will be used in AI processing. */
166
+ purpose: AiFilePurpose;
162
167
  /** The URL pointing to the file. */
163
168
  url: string;
169
+ /** An optional description of the file's content or purpose - sent to the AI. */
170
+ description?: string;
171
+ /** The file name, can be used in the prompt to reference the file. */
172
+ fileName?: string;
164
173
  }
174
+ /** The purpose of the AI file, used to determine how the file should be processed or utilized. */
175
+ export type AiFilePurpose = 'context' | 'tools';
165
176
  /**
166
177
  * Metadata for an AI agent connected to an integration.
167
178
  * @category AI
@@ -247,20 +258,16 @@ export interface AiAgentMemoryOptions {
247
258
  * @category AI
248
259
  */
249
260
  export interface BaseAiChatOptions {
250
- /** The maximum number of tokens to use when making the request to the AI model. Defaults to the max tokens the model can accept. */
251
- maxTokens?: number;
252
261
  /**
253
- * A unique chat ID, if the same chat ID is used again and history is not disabled, it will continue the conversation.
254
- * @deprecated use 'memoryOptions` instead.
262
+ * The maximum number of input tokens that Squid can use when making the request to the AI model.
263
+ * Defaults to the max tokens the model can accept.
255
264
  */
256
- chatId?: string;
265
+ maxTokens?: number;
257
266
  /**
258
- * Disables history for the agent, so each question is answered as
259
- * if it were the first question in the conversation.
260
- * Default to false.
261
- * @deprecated use 'memoryOptions` instead.
267
+ * The maximum number of tokens the model should output.
268
+ * Passed directly to the AI model. Can be used to control the output verbosity.
262
269
  */
263
- disableHistory?: boolean;
270
+ maxOutputTokens?: number;
264
271
  /** The context ID to use for the request. If not provided, the agent's default context will be used. */
265
272
  memoryOptions?: AiAgentMemoryOptions;
266
273
  /** Whether to disable the whole context for the request. Default to false. */
@@ -311,6 +318,22 @@ export interface BaseAiChatOptions {
311
318
  * connected agents, connected integrations, or functions.
312
319
  */
313
320
  executionPlanOptions?: AiAgentExecutionPlanOptions;
321
+ /** An array of file URLs to include in the chat context. */
322
+ fileUrls?: Array<AiFileUrl>;
323
+ /**
324
+ * The level of reasoning effort to apply; defaults to model-specific value.
325
+ * Effective only for models with reasoning.
326
+ */
327
+ reasoningEffort?: AiReasoningEffort;
328
+ /**
329
+ * Controls response length and detail level.
330
+ * Use `low` for brief responses, `medium` for balanced detail, or `high` for comprehensive explanations.
331
+ * Default: 'medium'.
332
+ *
333
+ * Note: this parameter is only supported by OpenAI plain text responses and is ignored for others.
334
+ * For other providers ask about verbosity in prompt and using `maxOutputTokens`.
335
+ */
336
+ verbosity?: AiVerbosityLevel;
314
337
  }
315
338
  /**
316
339
  * Chat options specific to Gemini models, extending base options.
@@ -337,23 +360,18 @@ export interface GrokChatOptions extends BaseAiChatOptions {
337
360
  export interface OpenAiChatOptions extends BaseAiChatOptions {
338
361
  /** The OpenAI model to use for the chat. */
339
362
  model?: OpenAiChatModelName;
340
- /** An array of file URLs to include in the chat context. */
341
- fileUrls?: Array<AiFileUrl>;
342
363
  }
343
364
  /**
365
+ * AI reasoning effort: Unsupported values are mapped to the closest supported option.
344
366
  * @category AI
345
367
  */
346
- export type AiReasoningEffort = 'low' | 'medium' | 'high';
368
+ export type AiReasoningEffort = 'minimal' | 'low' | 'medium' | 'high';
347
369
  /**
348
- * Chat options for OpenAI reasoning models, extending OpenAI options.
349
- * @category AI
370
+ * Controls response length and detail level.
371
+ * Use `low` for brief responses,`medium` for balanced detail, or `high` for comprehensive explanations.
372
+ * Default: 'medium'.
350
373
  */
351
- export interface OpenAiReasoningChatOptions extends OpenAiChatOptions {
352
- /** The OpenAI reasoning model to use for the chat. */
353
- model?: OpenAiReasoningChatModelName;
354
- /** The level of reasoning effort to apply; defaults to model-specific value. */
355
- reasoningEffort?: AiReasoningEffort;
356
- }
374
+ export type AiVerbosityLevel = 'low' | 'medium' | 'high';
357
375
  /**
358
376
  * Chat options specific to Anthropic models, extending base options.
359
377
  * @category AI
@@ -361,20 +379,18 @@ export interface OpenAiReasoningChatOptions extends OpenAiChatOptions {
361
379
  export interface AnthropicChatOptions extends BaseAiChatOptions {
362
380
  /** The Anthropic model to use for the chat. */
363
381
  model?: AnthropicChatModelName;
364
- /** The level of reasoning effort to apply. Defaults to no reasoning. */
365
- reasoningEffort?: AiReasoningEffort;
366
382
  }
367
383
  /**
368
384
  * The generic options type. When no generic is provided,
369
385
  * the type is inferred from the provided overrideModel (or falls back to BaseAiAgentChatOptions).
370
386
  * @category AI
371
387
  */
372
- export type AiChatOptions<T extends AiChatModelName | undefined = undefined> = T extends undefined ? BaseAiChatOptions | GeminiChatOptions | OpenAiReasoningChatOptions | OpenAiChatOptions | AnthropicChatOptions : T extends GeminiChatModelName ? GeminiChatOptions : T extends OpenAiReasoningChatModelName ? OpenAiReasoningChatOptions : T extends OpenAiChatModelName ? OpenAiChatOptions : T extends AnthropicChatModelName ? AnthropicChatOptions : T extends GrokChatModelName ? GrokChatOptions : never;
388
+ export type AiChatOptions<T extends AiChatModelName | undefined = undefined> = T extends undefined ? BaseAiChatOptions | GeminiChatOptions | OpenAiChatOptions | AnthropicChatOptions : T extends GeminiChatModelName ? GeminiChatOptions : T extends OpenAiChatModelName ? OpenAiChatOptions : T extends AnthropicChatModelName ? AnthropicChatOptions : T extends GrokChatModelName ? GrokChatOptions : never;
373
389
  /**
374
390
  * @category AI
375
391
  */
376
392
  export type AllAiAgentChatOptions = {
377
- [K in keyof BaseAiChatOptions | keyof GeminiChatOptions | keyof GrokChatOptions | keyof OpenAiReasoningChatOptions | keyof OpenAiChatOptions | keyof AnthropicChatOptions]?: (K extends keyof BaseAiChatOptions ? BaseAiChatOptions[K] : never) | (K extends keyof GeminiChatOptions ? GeminiChatOptions[K] : never) | (K extends keyof GrokChatOptions ? GrokChatOptions[K] : never) | (K extends keyof OpenAiReasoningChatOptions ? OpenAiReasoningChatOptions[K] : never) | (K extends keyof OpenAiChatOptions ? OpenAiChatOptions[K] : never) | (K extends keyof AnthropicChatOptions ? AnthropicChatOptions[K] : never);
393
+ [K in keyof BaseAiChatOptions | keyof GeminiChatOptions | keyof GrokChatOptions | keyof OpenAiChatOptions | keyof AnthropicChatOptions]?: (K extends keyof BaseAiChatOptions ? BaseAiChatOptions[K] : never) | (K extends keyof GeminiChatOptions ? GeminiChatOptions[K] : never) | (K extends keyof GrokChatOptions ? GrokChatOptions[K] : never) | (K extends keyof OpenAiChatOptions ? OpenAiChatOptions[K] : never) | (K extends keyof AnthropicChatOptions ? AnthropicChatOptions[K] : never);
378
394
  };
379
395
  /**
380
396
  * A definition of an AI agent with its properties and default chat options.
@@ -424,8 +440,8 @@ export interface AiStatusMessage {
424
440
  tags?: Record<string, any>;
425
441
  }
426
442
  /**
427
- * Name of the tag that contains ID of the parent message .
428
- * When the tag is present the current message should be considered in the context of the parent message.
443
+ * Name of the tag that contains ID of the parent message.
444
+ * When the tag is present, the current message should be considered in the context of the parent message.
429
445
  * Example: the message can contain a function call result.
430
446
  */
431
447
  export declare const AI_STATUS_MESSAGE_PARENT_MESSAGE_ID_TAG = "parent";
@@ -496,27 +512,31 @@ interface BaseContextRequest {
496
512
  * Status of an individual context item after successfully upserting it.
497
513
  * @category AI
498
514
  */
499
- export interface UpsertContextStatusSuccess {
500
- /** Whether the context upsert was successful or got an error. */
501
- status: 'success';
515
+ export interface BaseUpsertContextStatus {
516
+ /** Whether the context upsert was successful, otherwise, what occurred. */
517
+ status: 'success' | 'error';
502
518
  /** The unique identifier of the context item. */
503
519
  contextId: string;
504
520
  /** The name of the context item, typically the title or filename. */
505
521
  name: string;
506
522
  }
523
+ /**
524
+ * Status of an individual context item after successfully upserting it.
525
+ * @category AI
526
+ */
527
+ export interface UpsertContextStatusSuccess extends BaseUpsertContextStatus {
528
+ /** Whether the context upsert was successful or got an error. */
529
+ status: 'success';
530
+ }
507
531
  /**
508
532
  * Status of an individual context item after it failed to upsert.
509
533
  *
510
534
  * Contains the error message for why the upsert failed.
511
535
  * @category AI
512
536
  */
513
- export interface UpsertContextStatusError {
537
+ export interface UpsertContextStatusError extends BaseUpsertContextStatus {
514
538
  /** Whether the context upsert was successful or got an error. */
515
539
  status: 'error';
516
- /** The unique identifier of the context item. */
517
- contextId: string;
518
- /** The name of the context item, typically the title or filename. */
519
- name: string;
520
540
  /** Reason the upsert failed. */
521
541
  errorMessage: string;
522
542
  }
@@ -525,12 +545,20 @@ export interface UpsertContextStatusError {
525
545
  * @category AI
526
546
  */
527
547
  export type UpsertContextStatus = UpsertContextStatusSuccess | UpsertContextStatusError;
548
+ /**
549
+ * Response structure for upserting context.
550
+ * @category AI
551
+ */
552
+ export interface UpsertAgentContextResponse {
553
+ /** Upsert failure that occurred for the items sent in the request. */
554
+ failure?: UpsertContextStatusError;
555
+ }
528
556
  /**
529
557
  * Response structure for upserting contexts.
530
558
  * @category AI
531
559
  */
532
560
  export interface UpsertAgentContextsResponse {
533
- /** List of the upsert status of each item sent in the request. */
561
+ /** List of the upsert failures that occurred for the items sent in the request. */
534
562
  failures: Array<UpsertContextStatusError>;
535
563
  }
536
564
  /**
@@ -574,6 +602,16 @@ export interface FileContextRequest extends BaseContextRequest {
574
602
  extractionModel?: AiChatModelName;
575
603
  /** General options for how to process the file. */
576
604
  options?: AiContextFileOptions;
605
+ /** The preferred method for extracting data from the document. */
606
+ preferredExtractionMethod?: DocumentExtractionMethod;
607
+ /**
608
+ * Whether Squid keeps or discards the original file.
609
+ *
610
+ * Keeping the original file allows reprocessing and the ability for the user to download it later.
611
+ *
612
+ * Defaults to false.
613
+ */
614
+ discardOriginalFile?: boolean;
577
615
  }
578
616
  /**
579
617
  * Base options for how to deal with the content being upserted.
@@ -614,6 +652,8 @@ export interface AiTranscribeAndAskResponse {
614
652
  responseString: string;
615
653
  /** The transcribed text from the audio input. */
616
654
  transcribedPrompt: string;
655
+ /** The annotations associated with the AI response, if any. */
656
+ annotations?: Record<string, AiAnnotation>;
617
657
  }
618
658
  /** Per application AI settings. */
619
659
  export interface ApplicationAiSettings {
@@ -640,4 +680,13 @@ export interface UserAiAskResponse {
640
680
  /** The number of output tokens generated by the AI agent. */
641
681
  outputTokens?: number;
642
682
  }
683
+ /** Represents an annotation in the AI response. */
684
+ export type AiAnnotation = AiFileAnnotation;
685
+ /** Represents an annotation for a file in the AI response. */
686
+ export interface AiFileAnnotation {
687
+ /** The type of the annotation, always 'file'. */
688
+ type: 'file';
689
+ /** The AI file with the URL to the file */
690
+ aiFileUrl: AiFileUrl;
691
+ }
643
692
  export {};
@@ -16,18 +16,9 @@ export declare const AI_PROVIDER_TYPES: readonly ["anthropic", "flux", "gemini",
16
16
  */
17
17
  export type AiProviderType = (typeof AI_PROVIDER_TYPES)[number];
18
18
  /**
19
- * The supported OpenAI models.
20
19
  * @category AI
21
20
  */
22
- export declare const OPENAI_O1_CHAT_MODEL_NAMES: readonly ["o1"];
23
- /**
24
- * @category AI
25
- */
26
- export declare const OPENAI_REASONING_CHAT_MODEL_NAMES: readonly ["o1", "o3", "o3-mini", "o4-mini"];
27
- /**
28
- * @category AI
29
- */
30
- export declare const OPENAI_CHAT_MODEL_NAMES: readonly ["gpt-4o", "gpt-4o-mini", "gpt-4.1-nano", "gpt-4.1-mini", "gpt-4.1", "o1", "o3", "o3-mini", "o4-mini"];
21
+ export declare const OPENAI_CHAT_MODEL_NAMES: readonly ["o1", "o3", "o3-mini", "o4-mini", "gpt-5", "gpt-5-mini", "gpt-5-nano", "gpt-4.1", "gpt-4.1-mini", "gpt-4.1-nano", "gpt-4o", "gpt-4o-mini"];
31
22
  /**
32
23
  * @category AI
33
24
  */
@@ -44,12 +35,12 @@ export declare const GROK_CHAT_MODEL_NAMES: readonly ["grok-3", "grok-3-fast", "
44
35
  /**
45
36
  * @category AI
46
37
  */
47
- export declare const ANTHROPIC_CHAT_MODEL_NAMES: readonly ["claude-3-7-sonnet-latest", "claude-opus-4-20250514", "claude-sonnet-4-20250514"];
38
+ export declare const ANTHROPIC_CHAT_MODEL_NAMES: readonly ["claude-3-7-sonnet-latest", "claude-opus-4-20250514", "claude-opus-4-1-20250805", "claude-sonnet-4-20250514"];
48
39
  /**
49
40
  * The supported AI model names.
50
41
  * @category AI
51
42
  */
52
- export declare const VENDOR_AI_CHAT_MODEL_NAMES: readonly ["gpt-4o", "gpt-4o-mini", "gpt-4.1-nano", "gpt-4.1-mini", "gpt-4.1", "o1", "o3", "o3-mini", "o4-mini", "claude-3-7-sonnet-latest", "claude-opus-4-20250514", "claude-sonnet-4-20250514", "gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5-flash-lite", "grok-3", "grok-3-fast", "grok-3-mini", "grok-3-mini-fast", "grok-4"];
43
+ export declare const VENDOR_AI_CHAT_MODEL_NAMES: readonly ["o1", "o3", "o3-mini", "o4-mini", "gpt-5", "gpt-5-mini", "gpt-5-nano", "gpt-4.1", "gpt-4.1-mini", "gpt-4.1-nano", "gpt-4o", "gpt-4o-mini", "claude-3-7-sonnet-latest", "claude-opus-4-20250514", "claude-opus-4-1-20250805", "claude-sonnet-4-20250514", "gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5-flash-lite", "grok-3", "grok-3-fast", "grok-3-mini", "grok-3-mini-fast", "grok-4"];
53
44
  /**
54
45
  * Check if the given model name is a global AI chat model name.
55
46
  */
@@ -127,10 +118,6 @@ export type AiVoyageEmbeddingsModelName = (typeof VOYAGE_EMBEDDING_MODEL_NAMES)[
127
118
  * @category AI
128
119
  */
129
120
  export type OpenAiChatModelName = (typeof OPENAI_CHAT_MODEL_NAMES)[number];
130
- /**
131
- * @category AI
132
- */
133
- export type OpenAiReasoningChatModelName = (typeof OPENAI_REASONING_CHAT_MODEL_NAMES)[number];
134
121
  /**
135
122
  * @category AI
136
123
  */
@@ -1,6 +1,7 @@
1
- import { UpsertContextStatusError } from './ai-agent.public-types';
1
+ import { AnthropicChatOptions, BaseAiChatOptions, GeminiChatOptions, GrokChatOptions, OpenAiChatOptions, UpsertContextStatusError } from './ai-agent.public-types';
2
2
  import { AiChatModelName, AiEmbeddingsModelName, AiRerankProvider } from './ai-common.public-types';
3
3
  import { AiKnowledgeBaseId } from './communication.public-types';
4
+ import { DocumentExtractionMethod } from './extraction.public-types';
4
5
  /**
5
6
  * Represents an AI knowledge base that can be attached to an AI agent.
6
7
  * @category AI
@@ -16,6 +17,8 @@ export interface AiKnowledgeBase {
16
17
  metadataFields: Array<AiKnowledgeBaseMetadataField>;
17
18
  /** The embedding model name that should be used for this knowledge base.*/
18
19
  embeddingModel: AiEmbeddingsModelName;
20
+ /** The model name that should be used when asking questions of this knowledge base. */
21
+ chatModel: AiChatModelName;
19
22
  }
20
23
  /**
21
24
  * Represents a field in an AI knowledge base metadata.
@@ -186,6 +189,16 @@ export interface AiKnowledgeBaseFileContextRequest extends BaseAiKnowledgeBaseCo
186
189
  imageExtractionModel?: AiChatModelName;
187
190
  /** General options for how to process the file. */
188
191
  options?: AiKnowledgeBaseContextFileOptions;
192
+ /** The preferred method for extracting data from the document. */
193
+ preferredExtractionMethod?: DocumentExtractionMethod;
194
+ /**
195
+ * Whether Squid keeps or discards the original file.
196
+ *
197
+ * Keeping the original file allows reprocessing and the ability for the user to download it later.
198
+ *
199
+ * Defaults to false.
200
+ */
201
+ discardOriginalFile?: boolean;
189
202
  }
190
203
  /**
191
204
  * @category AI
@@ -206,21 +219,28 @@ export type BaseAiKnowledgeBaseContextOptions = {
206
219
  chunkOverlap?: number;
207
220
  };
208
221
  /**
209
- * The options for the AI agent search method.
222
+ * Specific options for the AI knowledgebase search method.
210
223
  * @category AI
211
224
  */
212
225
  export interface AiKnowledgeBaseSearchOptions {
213
226
  /** The prompt to search for */
214
227
  prompt: string;
215
- /** A set of filters that will limit the context the AI can access */
216
- contextMetadataFilter?: AiContextMetadataFilter;
217
228
  /** The maximum number of results to return */
218
229
  limit?: number;
219
230
  /** Which provider's reranker to use for reranking the context. Defaults to 'cohere'. */
220
231
  rerankProvider?: AiRerankProvider;
221
232
  /** How many chunks to look over. Defaults to 100 */
222
233
  chunkLimit?: number;
234
+ /** Which chat model to use when asking the question */
235
+ chatModel?: string;
223
236
  }
237
+ /**
238
+ * The options for the AI knowledgebase search method.
239
+ * @category AI
240
+ */
241
+ export type AllAiKnowledgeBaseChatOptions = {
242
+ [K in keyof BaseAiChatOptions | keyof GeminiChatOptions | keyof GrokChatOptions | keyof OpenAiChatOptions | keyof AiKnowledgeBaseSearchOptions | keyof AnthropicChatOptions]?: (K extends keyof BaseAiChatOptions ? BaseAiChatOptions[K] : never) | (K extends keyof GeminiChatOptions ? GeminiChatOptions[K] : never) | (K extends keyof GrokChatOptions ? GrokChatOptions[K] : never) | (K extends keyof OpenAiChatOptions ? OpenAiChatOptions[K] : never) | (K extends keyof AnthropicChatOptions ? AnthropicChatOptions[K] : never) | (K extends keyof AiKnowledgeBaseSearchOptions ? AiKnowledgeBaseSearchOptions[K] : never);
243
+ };
224
244
  /**
225
245
  * A single chunk of data returned from an AI search operation.
226
246
  * @category AI
@@ -237,8 +257,35 @@ export interface AiKnowledgeBaseSearchResultChunk {
237
257
  * Response structure for upserting context for an AiKnowledgeBase
238
258
  * @category AI
239
259
  */
260
+ export interface UpsertKnowledgeBaseContextResponse {
261
+ /** List of the upsert status of each item sent in the request. */
262
+ failure?: UpsertContextStatusError;
263
+ }
264
+ /**
265
+ * Response structure for upserting contexts for an AiKnowledgeBase
266
+ * @category AI
267
+ */
240
268
  export interface UpsertKnowledgeBaseContextsResponse {
241
269
  /** List of the upsert status of each item sent in the request. */
242
270
  failures: Array<UpsertContextStatusError>;
243
271
  }
272
+ /**
273
+ * Request structure for searching an AiKnowledgeBase
274
+ * @category AI
275
+ */
276
+ export interface AiKnowledgeBaseSearchRequest {
277
+ /** The id of the AiKnowledgeBase */
278
+ knowledgeBaseId: string;
279
+ /** The user prompt to search on */
280
+ prompt: string;
281
+ /** The search options for this search */
282
+ options: AiKnowledgeBaseSearchOptions;
283
+ }
284
+ /**
285
+ * KnowledgeBase with optional chatModel param, used during upsert
286
+ * @category AI
287
+ */
288
+ export type AiKnowledgeBaseWithOptionalChatModel = Omit<AiKnowledgeBase, 'chatModel'> & {
289
+ chatModel?: AiKnowledgeBase['chatModel'];
290
+ };
244
291
  export {};
@@ -1,4 +1,4 @@
1
- import { AiChatModelName } from './ai-common.public-types';
1
+ import { AiChatOptions } from './ai-agent.public-types';
2
2
  import { ApiOptions } from './api-client.public-types';
3
3
  import { IntegrationId } from './communication.public-types';
4
4
  /**
@@ -20,21 +20,65 @@ export interface ExecuteAiQueryRequest {
20
20
  * @category AI
21
21
  */
22
22
  export interface ExecuteAiQueryOptions {
23
- /** Custom instructions to modify AI query behavior. */
23
+ /**
24
+ * Custom instructions to modify AI query generation behavior.
25
+ * Used for all stages unless there is a per-stage override.
26
+ */
24
27
  instructions?: string;
25
- /** List of collections to use in the AI query. */
26
- collectionsToUse?: Array<string>;
27
28
  /** Whether to enable raw results output. */
28
29
  enableRawResults?: boolean;
29
- /** Whether to enable code interpreter for query execution. */
30
- enableCodeInterpreter?: boolean;
31
- /** Specific AI model override for the query execution. */
32
- overrideModel?: AiChatModelName;
33
30
  /** Whether to generate a step-by-step walkthrough for the response. */
34
31
  generateWalkthrough?: boolean;
35
- /** The number of allowed retries in case of errors during query execution. Defaults to 2. */
32
+ /** Options for the collection selection stage. */
33
+ selectCollectionsOptions?: AiQuerySelectCollectionsOptions;
34
+ /** Options for the query generation stage. */
35
+ generateQueryOptions?: AiQueryGenerateQueryOptions;
36
+ /** Options specify how to query result should be analyzed (processed) before returning it to user. */
37
+ analyzeResultsOptions?: AiQueryAnalyzeResultsOptions;
38
+ }
39
+ /**
40
+ * Options for the collection selection stage.
41
+ *
42
+ * At this stage Squid selects a subset of collections that will be used by the later stage to generate the real query.
43
+ * It is recommended that the set of collections selected by this stage be broad enough so the query generation stage
44
+ * has a good view of the database.
45
+ */
46
+ export interface AiQuerySelectCollectionsOptions {
47
+ /**
48
+ * Limits collections to be used in the query only to these collections.
49
+ * When not provided, all collections are used.
50
+ */
51
+ collectionsToUse?: string[];
52
+ /** Defines the stage algorithm. Default: 'auto'. */
53
+ runMode?: AiQueryCollectionsSelectionRunMode;
54
+ /** Used to customize AI agent behavior used by the stage. */
55
+ aiOptions?: AiChatOptions;
56
+ }
57
+ /**
58
+ * Defines the stage behavior:
59
+ * - 'default' - Squid will decide if to run the collection selection algorithm or not.
60
+ * - 'force' - Collection selection algorithm is run always, even if collectionsToUse are provided.
61
+ * - 'disable' - The stage is disabled. The whole schema (or collectionsToUse) will be passed to the next step.
62
+ */
63
+ export type AiQueryCollectionsSelectionRunMode = 'default' | 'force' | 'disable';
64
+ /**
65
+ * Options for the query generation stage.
66
+ *
67
+ * At this stage Squid generates the database native query based on the user prompt and a set of collections selected
68
+ * in the previous stage. */
69
+ export interface AiQueryGenerateQueryOptions {
70
+ /** Customizes AI agent behavior used by the stage. */
71
+ aiOptions?: AiChatOptions;
72
+ /** Number of retries due to errors in a generated AI query. Default: 2. */
36
73
  maxErrorCorrections?: number;
37
74
  }
75
+ /** Options for the query result analysis. */
76
+ export interface AiQueryAnalyzeResultsOptions {
77
+ /** Enables or disables code interpreter mode. Default: 'false'. */
78
+ enableCodeInterpreter?: boolean;
79
+ /** Customizes AI agent behavior used by the stage. */
80
+ aiOptions?: AiChatOptions;
81
+ }
38
82
  /**
39
83
  * Response from an AI query execution.
40
84
  * Contains the generated answer, optional explanation, and executed query details.
@@ -61,7 +105,7 @@ export interface ExecuteAiQueryResponse {
61
105
  export interface ExecutedQuery {
62
106
  /** Text of the executed query. */
63
107
  query: string;
64
- /** The markdown type of the result (sql, mongo, etc.). */
108
+ /** The Markdown type of the result (sql, mongo, etc.). */
65
109
  markdownType: string;
66
110
  /** URL to access raw results from the query execution. */
67
111
  rawResultsUrl?: string;
@@ -89,10 +133,10 @@ export interface AiApiResult {
89
133
  /** ID of the executed API endpoint. */
90
134
  endpointId: string;
91
135
  /** Name of the executed API endpoint. */
92
- responseBody: string;
136
+ responseBody: string | object;
93
137
  /** Status code of the executed API request. */
94
138
  responseStatusCode: number;
95
- /** Request body of the executed API request. */
139
+ /** Request's body of the executed API request. */
96
140
  requestBody: any;
97
141
  /** Request options of the executed API request. */
98
142
  requestOptions: ApiOptions;
@@ -23,7 +23,7 @@ export interface ApiRequestField {
23
23
  required?: boolean;
24
24
  }
25
25
  /** The options for calling an API. */
26
- export interface CallApiOptions {
26
+ export interface InternalCallApiOptions {
27
27
  /** If true, the response will be returned as-is without any processing. */
28
28
  nativeResponse?: boolean;
29
29
  /**
@@ -32,15 +32,6 @@ export interface CallApiOptions {
32
32
  */
33
33
  originOverride?: string;
34
34
  }
35
- /** A native API call response. */
36
- export interface NativeApiCallResponse<BodyType = unknown> {
37
- /** The response body, typed according to the expected content. */
38
- body: BodyType;
39
- /** A record of HTTP headers returned in the response. */
40
- headers: Record<string, string>;
41
- /** The HTTP status code of the response. */
42
- status: number;
43
- }
44
35
  /** Describes a field included in an API response, optionally including the field path and a description. */
45
36
  export interface ApiResponseField {
46
37
  /** The location of the field in the API response (e.g., header, body). */
@@ -16,7 +16,7 @@ export type SquidDocId = string;
16
16
  export type ClientRequestId = string;
17
17
  /** ID of AI agent. Also known as AI profile id. */
18
18
  export type AiAgentId = string;
19
- /** ID of AI Knowledge Base */
19
+ /** App-level ID of AI Knowledge Base */
20
20
  export type AiKnowledgeBaseId = string;
21
21
  /**
22
22
  * The built-in agent id. Cannot be customized.
@@ -22,6 +22,14 @@ export interface ExtractDataFromDocumentOptions {
22
22
  * The preferred method for extracting data from the document.
23
23
  */
24
24
  preferredExtractionMethod?: DocumentExtractionMethod;
25
+ /**
26
+ * Whether Squid keeps or discards the original file.
27
+ *
28
+ * Keeping the original file allows reprocessing and the ability for the user to download it later.
29
+ *
30
+ * Defaults to false.
31
+ */
32
+ discardOriginalFile?: boolean;
25
33
  }
26
34
  /**
27
35
  * Request payload for extracting data from a document via URL.
@@ -91,6 +99,10 @@ export interface ExtractDataFromDocumentResponse {
91
99
  * Array of pages containing extracted data.
92
100
  */
93
101
  pages: Array<ExtractDataFromDocumentPage>;
102
+ /**
103
+ * Path to the original file in cloud storage, if applicable.
104
+ */
105
+ longTermStoragePath?: string;
94
106
  }
95
107
  /**
96
108
  * Create PDF request type.
@@ -1,6 +1,6 @@
1
1
  import { IntegrationId } from './communication.public-types';
2
2
  /** List of all integration types supported by Squid. */
3
- export declare const INTEGRATION_TYPES: readonly ["active_directory", "ai_agents", "ai_chatbot", "algolia", "alloydb", "api", "auth0", "azure_cosmosdb", "azure_postgresql", "azure_sql", "bigquery", "built_in_db", "built_in_gcs", "built_in_queue", "built_in_s3", "cassandra", "clickhouse", "cloudsql", "cockroach", "cognito", "confluence", "confluent", "datadog", "db2", "descope", "documentdb", "dynamodb", "elasticsearch", "firebase_auth", "firestore", "gcs", "google_docs", "google_drive", "graphql", "hubspot", "jira", "jwt_hmac", "jwt_rsa", "kafka", "linear", "mariadb", "monday", "mongo", "mssql", "databricks", "mysql", "newrelic", "okta", "onedrive", "oracledb", "pinecone", "postgres", "redis", "s3", "salesforce_crm", "sap_hana", "sentry", "servicenow", "snowflake", "spanner", "xata", "zendesk", "mail", "slack", "mcp", "a2a"];
3
+ export declare const INTEGRATION_TYPES: readonly ["active_directory", "ai_agents", "ai_knowledgebases", "ai_chatbot", "algolia", "alloydb", "api", "auth0", "azure_cosmosdb", "azure_postgresql", "azure_sql", "bigquery", "built_in_db", "built_in_gcs", "built_in_queue", "built_in_s3", "cassandra", "clickhouse", "cloudsql", "cockroach", "cognito", "confluence", "confluent", "datadog", "db2", "descope", "documentdb", "dynamodb", "elasticsearch", "firebase_auth", "firestore", "gcs", "google_docs", "google_drive", "graphql", "hubspot", "jira", "jwt_hmac", "jwt_rsa", "kafka", "linear", "mariadb", "monday", "mongo", "mssql", "databricks", "mysql", "newrelic", "okta", "onedrive", "oracledb", "pinecone", "postgres", "redis", "s3", "salesforce_crm", "sap_hana", "sentry", "servicenow", "snowflake", "spanner", "xata", "zendesk", "mail", "slack", "mcp", "a2a"];
4
4
  /**
5
5
  * @category Database
6
6
  */
@@ -1,8 +1,8 @@
1
1
  import { Observable } from 'rxjs';
2
- import { AgentContextRequest, AiAgent, AiAgentContext, AiConnectedAgentMetadata, AiSearchOptions, AiSearchResultChunk, AiStatusMessage, AiTranscribeAndAskResponse, GuardrailsOptions, UpsertAgentContextsResponse, UpsertAgentRequest } from '../../../internal-common/src/public-types/ai-agent.public-types';
2
+ import { AgentContextRequest, AiAgent, AiAgentContext, AiConnectedAgentMetadata, AiSearchOptions, AiSearchResultChunk, AiStatusMessage, AiTranscribeAndAskResponse, GuardrailsOptions, UpsertAgentContextResponse, UpsertAgentContextsResponse, UpsertAgentRequest } from '../../../internal-common/src/public-types/ai-agent.public-types';
3
3
  import { AiChatModelName } from '../../../internal-common/src/public-types/ai-common.public-types';
4
4
  import { JobId } from '../../../internal-common/src/public-types/job.public-types';
5
- import { AiAskOptions, AiAskOptionsWithVoice, AiChatOptionsWithoutVoice, AskWithVoiceResponse, TranscribeAndAskWithVoiceResponse, TranscribeAndChatResponse } from './ai-agent-client.types';
5
+ import { AiAskOptions, AiAskOptionsWithVoice, AiChatOptionsWithoutVoice, AskResponse, AskWithVoiceResponse, TranscribeAndAskWithVoiceResponse, TranscribeAndChatResponse } from './ai-agent-client.types';
6
6
  /**
7
7
  * Parameters for creating or updating an AI agent.
8
8
  * Excludes the `id` field, as it is derived from the agent instance.
@@ -64,7 +64,7 @@ export declare class AiAgentReference {
64
64
  /**
65
65
  * Adds or updates a single agent context.
66
66
  */
67
- upsertContext(contextRequest: AgentContextRequest, file?: File): Promise<void>;
67
+ upsertContext(contextRequest: AgentContextRequest, file?: File): Promise<UpsertAgentContextResponse>;
68
68
  /**
69
69
  * Adds or updates multiple agent contexts.
70
70
  */
@@ -112,7 +112,7 @@ export declare class AiAgentReference {
112
112
  */
113
113
  search(options: AiSearchOptions): Promise<Array<AiSearchResultChunk>>;
114
114
  /**
115
- * Sends a prompt and receives a full string response.
115
+ * Sends a prompt and returns a full string response.
116
116
  * @param prompt The text prompt to send to the agent.
117
117
  * @param options Optional parameters for the AI ask request.
118
118
  * @param jobId (Optional) A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
@@ -120,9 +120,19 @@ export declare class AiAgentReference {
120
120
  * knows it can look up the job’s status.
121
121
  */
122
122
  ask<T extends AiChatModelName | undefined = undefined>(prompt: string, options?: AiAskOptions<T>, jobId?: JobId): Promise<string>;
123
+ /**
124
+ * Sends a prompt and returns the string response and file annotations.
125
+ * @param prompt The text prompt to send to the agent.
126
+ * @param options Optional parameters for the AI ask request.
127
+ * @param jobId (Optional) A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
128
+ * `squid.jobs().getJob(jobId)` to track progress. Make sure each job ID is both unique and kept private—anyone who
129
+ * knows it can look up the job’s status.
130
+ */
131
+ askWithAnnotations<T extends AiChatModelName | undefined = undefined>(prompt: string, options?: AiAskOptions<T>, jobId?: JobId): Promise<AskResponse>;
123
132
  /**
124
133
  * Sends a prompt and not wait for the result - the result can be tracked using the job ID
125
134
  * (`squid.jobs().awaitJob(jobId)` or `squid.jobs().getJob(jobId)).
135
+ * The result is of type AiAskResponse which contains the response string and optional annotations.
126
136
  * @param prompt The text prompt to send to the agent.
127
137
  * @param jobId A unique identifier for this request. Use it with `squid.jobs().awaitJob(jobId)` or
128
138
  * `squid.jobs().getJob(jobId)`
@@ -1,5 +1,5 @@
1
1
  import { Observable } from 'rxjs';
2
- import { AiChatOptions } from '../../../internal-common/src/public-types/ai-agent.public-types';
2
+ import { AiAnnotation, AiChatOptions } from '../../../internal-common/src/public-types/ai-agent.public-types';
3
3
  import { AiChatModelName } from '../../../internal-common/src/public-types/ai-common.public-types';
4
4
  /**
5
5
  * Response format for transcribing audio and generating a chat response.
@@ -25,6 +25,16 @@ export interface TranscribeAndAskWithVoiceResponse {
25
25
  /** AI-generated voice response as an audio file. */
26
26
  voiceResponseFile: File;
27
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
+ }
28
38
  /**
29
39
  * Response format for AI-generated voice responses.
30
40
  * Contains the AI-generated text response and the corresponding audio file.