@squidcloud/client 1.0.488 → 1.0.490

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 (55) 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-integrations.public-types.d.ts +8 -0
  4. package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +128 -4
  5. package/dist/internal-common/src/public-types/ai-common.public-types.d.ts +21 -9
  6. package/dist/internal-common/src/public-types/ai-knowledge-base.public-types.d.ts +262 -6
  7. package/dist/internal-common/src/public-types/connector.public-types.d.ts +1 -1
  8. package/dist/internal-common/src/public-types/extraction.public-types.d.ts +28 -1
  9. package/dist/internal-common/src/public-types/integration.public-types.d.ts +10 -2
  10. package/dist/internal-common/src/public-types/source-code.public-types.d.ts +12 -0
  11. package/dist/internal-common/src/public-types/web.public-types.d.ts +18 -1
  12. package/dist/typescript-client/src/ai-knowledge-base/ai-knowledge-base-client-reference.d.ts +31 -3
  13. package/dist/typescript-client/src/integration-client.d.ts +30 -3
  14. package/dist/typescript-client/src/query-utils.d.ts +14 -2
  15. package/dist/typescript-client/src/version.d.ts +1 -1
  16. package/dist/typescript-client/src/web-client.d.ts +4 -2
  17. package/package.json +1 -1
  18. package/dist/internal-common/src/ai/system-openai-compatible.d.ts +0 -35
  19. package/dist/internal-common/src/metric-name.d.ts +0 -14
  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 -161
  22. package/dist/internal-common/src/public-types-backend/native-query.public-context.d.ts +0 -75
  23. package/dist/internal-common/src/public-types-backend/query.public-context.d.ts +0 -193
  24. package/dist/internal-common/src/types/ai-agent.types.d.ts +0 -302
  25. package/dist/internal-common/src/types/ai-knowledge-base.types.d.ts +0 -306
  26. package/dist/internal-common/src/types/ai-matchmaking.types.d.ts +0 -19
  27. package/dist/internal-common/src/types/backend-function.types.d.ts +0 -1
  28. package/dist/internal-common/src/types/communication.types.d.ts +0 -1
  29. package/dist/internal-common/src/types/document.types.d.ts +0 -1
  30. package/dist/internal-common/src/types/file.types.d.ts +0 -6
  31. package/dist/internal-common/src/types/headers.types.d.ts +0 -41
  32. package/dist/internal-common/src/types/management-api-key.types.d.ts +0 -92
  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 -19
  35. package/dist/internal-common/src/types/observability.types.d.ts +0 -168
  36. package/dist/internal-common/src/types/query.types.d.ts +0 -15
  37. package/dist/internal-common/src/types/secret.types.d.ts +0 -7
  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 -45
  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/file-utils.d.ts +0 -2
  45. package/dist/internal-common/src/utils/global.utils.d.ts +0 -1
  46. package/dist/internal-common/src/utils/http.d.ts +0 -10
  47. package/dist/internal-common/src/utils/lock.manager.d.ts +0 -14
  48. package/dist/internal-common/src/utils/metric-utils.d.ts +0 -4
  49. package/dist/internal-common/src/utils/metrics.types.d.ts +0 -7
  50. package/dist/internal-common/src/utils/object.d.ts +0 -86
  51. package/dist/internal-common/src/utils/serialization.d.ts +0 -24
  52. package/dist/internal-common/src/utils/squid.constants.d.ts +0 -6
  53. package/dist/internal-common/src/utils/trace-id-generator.d.ts +0 -1
  54. package/dist/internal-common/src/utils/validation.d.ts +0 -19
  55. package/dist/internal-common/src/websocket.impl.d.ts +0 -26
@@ -48,6 +48,14 @@ export interface AiApiOptions {
48
48
  * Defaults to no memory.
49
49
  */
50
50
  memoryOptions?: AiAgentMemoryOptions;
51
+ /**
52
+ * How long, in milliseconds, a single AI call of the loop may wait for the provider — endpoint
53
+ * selection, request-body creation and response analysis each get this budget on their own, so
54
+ * the whole call may run for a multiple of it. Values below the chat minimum of 20 000 ms are
55
+ * raised to it. Defaults to the standard chat timeout, or to the timeout of the chat this call
56
+ * runs inside when the caller is a nested one.
57
+ */
58
+ stageTimeoutMs?: number;
51
59
  }
52
60
  /**
53
61
  * Configuration options for AI agent MCP integration.
@@ -420,6 +420,26 @@ export interface IntegrationModelSpec {
420
420
  * @category AI
421
421
  */
422
422
  export type AiChatModelSelection = AiChatModelName | IntegrationModelSpec;
423
+ /**
424
+ * A backup model together with the sampling settings to run it with. Use this form instead of a
425
+ * bare {@link AiChatModelSelection} when the backup needs settings of its own; anything left unset
426
+ * takes the backup model's own default rather than the primary model's value.
427
+ * @category AI
428
+ */
429
+ export interface BackupModelOptions {
430
+ /** The model to fall back to. */
431
+ model: AiChatModelSelection;
432
+ /** The temperature to use when sampling from the backup model. */
433
+ temperature?: number;
434
+ /** The level of reasoning effort to apply; effective only for models with reasoning. */
435
+ reasoningEffort?: AiReasoningEffort;
436
+ /** The maximum number of input tokens Squid may send to the backup model. */
437
+ maxTokens?: number;
438
+ /** The maximum number of tokens the backup model should output. */
439
+ maxOutputTokens?: number;
440
+ /** Response length and detail level; supported by OpenAI models only. */
441
+ verbosity?: AiVerbosityLevel;
442
+ }
423
443
  /**
424
444
  * The base AI agent chat options, should not be used directly.
425
445
  * @category AI
@@ -459,8 +479,24 @@ export interface BaseAiChatOptions {
459
479
  legacyKnowledgeBaseContext?: boolean;
460
480
  /** Rewrite prompt for RAG - defaults to false */
461
481
  enablePromptRewriteForRag?: boolean;
462
- /** Whether to include references from the source context in the response. Default to false. */
482
+ /**
483
+ * Whether to include references from the source context in the response. Default to false.
484
+ * @deprecated Use citation instead. Kept for compatibility; renders the legacy Quote/Source format
485
+ * on the legacy upfront-RAG path only.
486
+ */
463
487
  includeReference?: boolean;
488
+ /**
489
+ * When true, the agent cites the sources behind its statements: source name, plus a download link
490
+ * when the agent's stored options set `allowSourceDownloads`. Takes precedence over the deprecated
491
+ * `includeReference`. Default to false.
492
+ */
493
+ citation?: boolean;
494
+ /**
495
+ * Allows citation links to the original source files (presigned, 1h expiry). Honored ONLY from the
496
+ * agent's stored options — the per-request value is ignored, so callers of public agents can never
497
+ * enable downloads. Default to false (citations render source names only).
498
+ */
499
+ allowSourceDownloads?: boolean;
464
500
  /**
465
501
  * The format of the response from the AI model. Defaults to 'text'. A `json_schema` format is
466
502
  * refused for a model whose provider has no way to carry a schema — see
@@ -512,6 +548,52 @@ export interface BaseAiChatOptions {
512
548
  pii?: AiPiiOptions;
513
549
  /** The LLM model to use. Can be a vendor model name (string) or an integration-based model (object). */
514
550
  model?: AiChatModelSelection;
551
+ /**
552
+ * The model to use when `model` cannot serve the conversation's very first request because its
553
+ * provider is unavailable — a rate limit, a capacity outage, or any other failure on the
554
+ * provider's side. A request that fails for its own reasons (an invalid prompt, a rejected
555
+ * schema, an exhausted Squid quota) is never retried on the backup, nor is any request after the
556
+ * first one, nor one that already produced output or ran a tool.
557
+ *
558
+ * A conversation that fell back then STAYS on that backup for the rest of its life, so an outage
559
+ * costs the primary's retry budget once rather than once per turn, and the model does not change
560
+ * mid-dialogue. The pin outlives the option that created it: changing or removing `backupModel`,
561
+ * changing the agent's own `model`, and the primary recovering all leave a pinned conversation
562
+ * where it is, and a pinned model that no longer resolves fails the request rather than moving the
563
+ * conversation. This is deliberate — a conversation accumulates provider-native file ids and a
564
+ * transcript in that provider's dialect, none of which survive a move. Pinning needs Squid-managed
565
+ * memory to have somewhere to record it; without memory every request is a first request anyway.
566
+ *
567
+ * A request carrying `fileIds` follows from the same reasoning, and the two cases differ. A first
568
+ * request does not fall back where that would cost it the attachments — to a model that cannot read
569
+ * ids the primary could, or that reads them without owning them — since answering from a model that
570
+ * never saw them is worse than reporting the outage. Where neither model reads file ids they are
571
+ * inert either way and the fallback proceeds. A
572
+ * conversation already pinned is held to less: it keeps running on its model, and if that model
573
+ * reads no file ids the ids are ignored there as they are anywhere else, because the alternative is
574
+ * a conversation that can never run again.
575
+ *
576
+ * Pass a model name for the model's own defaults, or a {@link BackupModelOptions} object to give
577
+ * the backup its own sampling settings. Everything else — instructions, functions, knowledge
578
+ * bases, connected agents, response format, memory — always comes from the primary configuration.
579
+ *
580
+ * On a turn the backup serves, the sampling settings are ITS settings alone: `temperature`,
581
+ * `reasoningEffort`, `maxTokens`, `maxOutputTokens` and `verbosity` are read from `backupModel`
582
+ * and nowhere else, so a value left unset there takes the backup model's own default even when
583
+ * the agent's profile or the request itself carries one. This holds for every turn of a pinned
584
+ * conversation, not only the one that fell back — tuning meant for one model is not evidence of
585
+ * what another should use.
586
+ *
587
+ * Applies to models served through Squid's own provider SDKs — the vendor models and
588
+ * `openai_compatible`, Bedrock and Vertex integrations. A model you serve yourself from backend
589
+ * code reports its failures as plain errors that carry no provider status, so a turn on one is
590
+ * never diagnosed as a provider outage and never falls back.
591
+ *
592
+ * The backup resolves its API key exactly as it would as the primary model, and is skipped
593
+ * silently when it cannot be resolved, when it reaches the same model as the primary, or when
594
+ * either model is a CLI-backed agent. Leave unset to keep a provider outage surfacing as an error.
595
+ */
596
+ backupModel?: AiChatModelSelection | BackupModelOptions;
515
597
  /** Which provider's reranker to use for reranking the context. Defaults to 'cohere'. */
516
598
  rerankProvider?: AiRerankProvider;
517
599
  /**
@@ -559,8 +641,21 @@ export interface BaseAiChatOptions {
559
641
  * Files are attached to the conversation and can be read/analyzed by the AI.
560
642
  */
561
643
  fileIds?: string[];
562
- /** Timeout in milliseconds for the entire chat request. Defaults to 240,000 (4 minutes). */
644
+ /**
645
+ * Timeout in milliseconds for one model-call attempt of the chat (a single provider call,
646
+ * covering that call's tool loop). An attempt that produced nothing by this deadline is treated
647
+ * as a stalled provider connection and retried per `retriesOnStall`, each retry getting this
648
+ * full budget again — so the provider phase of a chat may take up to
649
+ * `(1 + retriesOnStall) * timeoutMs` in the worst case. Defaults to 240,000 (4 minutes).
650
+ */
563
651
  timeoutMs?: number;
652
+ /**
653
+ * How many times a stalled model-call attempt is reissued. A retry happens only when the
654
+ * attempt hit `timeoutMs` having produced nothing AND no AI function has executed in the turn,
655
+ * so a retry can never repeat a side effect; aborting the stalled attempt destroys its
656
+ * connection, so the retry cannot reuse it. `0` disables stall retries. Defaults to 1.
657
+ */
658
+ retriesOnStall?: number;
564
659
  /** Maximum number of tool-call iterations the model may perform in a single chat turn. Defaults to 50. */
565
660
  maxToolIterations?: number;
566
661
  }
@@ -607,6 +702,11 @@ export type { CanonicalReasoningEffort } from './ai-common.public-types';
607
702
  * - unknown string the model cannot place on the axis -> dropped, so the model's own default applies,
608
703
  * with a warning;
609
704
  * - model without a reasoning knob -> ignored, with a warning.
705
+ *
706
+ * A model served through an `openai_compatible` integration is the exception: the value is sent to
707
+ * that endpoint exactly as written, with none of the resolution above, since the endpoint's model is
708
+ * the app's own choice and this registry cannot describe it. That is also how to reach a level the
709
+ * canonical set has no name for.
610
710
  * @category AI
611
711
  */
612
712
  export type AiReasoningEffort = CanonicalReasoningEffort | (string & {});
@@ -918,6 +1018,18 @@ export interface BaseUpsertContextStatus {
918
1018
  /** The name of the context item, typically the title or filename. */
919
1019
  name: string;
920
1020
  }
1021
+ /**
1022
+ * An image whose description failed during ingestion: the context is stored without that image's chunk.
1023
+ * @category AI
1024
+ */
1025
+ export interface ContextImageFailure {
1026
+ /** Zero-based index of the page carrying the image. */
1027
+ pageIndex: number;
1028
+ /** Extraction-assigned id of the image within the document. */
1029
+ imageId: string;
1030
+ /** Why describing the image failed. */
1031
+ errorMessage: string;
1032
+ }
921
1033
  /**
922
1034
  * Status of an individual context item after successfully upserting it.
923
1035
  * @category AI
@@ -931,15 +1043,23 @@ export interface UpsertContextStatusSuccess extends BaseUpsertContextStatus {
931
1043
  * surfaced so bulk operations can report which contexts fell outside the graph.
932
1044
  */
933
1045
  graphIndexingSkipped?: boolean;
1046
+ /** First failed images (capped); absent when every image succeeded. `imageFailureCount` is the total. */
1047
+ imageFailures?: Array<ContextImageFailure>;
1048
+ /** Total number of failed images, which exceeds `imageFailures.length` when the list was capped. */
1049
+ imageFailureCount?: number;
934
1050
  }
935
1051
  /**
936
1052
  * Machine-readable code identifying a specific upsert failure reason.
937
1053
  *
938
1054
  * `DUPLICATE_CONTENT` means the request omitted a contextId and its content is
939
1055
  * byte-identical to an existing context in the same knowledge base.
1056
+ *
1057
+ * `EMBEDDING_FAILED` means extraction succeeded but embedding the context's chunks did not; the
1058
+ * content was not written (an overwrite target keeps its previous content) and the request can be
1059
+ * safely retried as-is.
940
1060
  * @category AI
941
1061
  */
942
- export type UpsertContextErrorCode = 'DUPLICATE_CONTENT';
1062
+ export type UpsertContextErrorCode = 'DUPLICATE_CONTENT' | 'EMBEDDING_FAILED';
943
1063
  /**
944
1064
  * The existing context a `DUPLICATE_CONTENT` rejection points at — where the byte-identical original
945
1065
  * already lives.
@@ -972,6 +1092,10 @@ export interface UpsertContextStatusError extends BaseUpsertContextStatus {
972
1092
  * rejection. `reference`/`folderPath` are present when the existing context carries them.
973
1093
  */
974
1094
  duplicateOf?: UpsertContextDuplicateOf;
1095
+ /** First failed images (capped) when every image failed and the document had no text; otherwise absent. */
1096
+ imageFailures?: Array<ContextImageFailure>;
1097
+ /** Total number of failed images, which exceeds `imageFailures.length` when the list was capped. */
1098
+ imageFailureCount?: number;
975
1099
  }
976
1100
  /**
977
1101
  * Status of an individual context item after attempting to upsert it.
@@ -1164,7 +1288,7 @@ export interface UserAiChatOptions extends BaseAiChatOptions {
1164
1288
  export interface UserAiAskResponse {
1165
1289
  /** The response from the AI agent. */
1166
1290
  response?: string;
1167
- /** The number of input tokens used in the request. */
1291
+ /** Prompt tokens used by the request, including any the prompt cache served. */
1168
1292
  inputTokens?: number;
1169
1293
  /** The number of output tokens generated by the AI agent. */
1170
1294
  outputTokens?: number;
@@ -2,7 +2,7 @@ import { UserAiChatModelName } from './backend.public-types';
2
2
  /**
3
3
  * @category AI
4
4
  */
5
- export declare const RERANK_PROVIDERS: readonly ["cohere", "none"];
5
+ export declare const RERANK_PROVIDERS: readonly ["cohere", "voyage", "none"];
6
6
  /**
7
7
  * @category AI
8
8
  */
@@ -20,36 +20,48 @@ export type AiProviderType = (typeof AI_PROVIDER_TYPES)[number];
20
20
  * @category AI
21
21
  */
22
22
  export type CanonicalReasoningEffort = 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'ultra';
23
+ /**
24
+ * The AI providers that support file upload operations, and so are the only ones that resolve a
25
+ * pre-uploaded file id. Declared as the list, with the type derived from it, so the two cannot drift:
26
+ * a provider added to one is added to both.
27
+ */
28
+ export declare const AI_FILE_PROVIDER_TYPES: readonly ["openai", "gemini", "anthropic", "grok"];
23
29
  /**
24
30
  * Type of AI provider that supports file upload operations.
25
31
  * Only a subset of AI providers support file management features.
26
32
  */
27
- export type AiFileProviderType = Extract<AiProviderType, 'openai' | 'gemini' | 'anthropic' | 'grok'>;
33
+ export type AiFileProviderType = (typeof AI_FILE_PROVIDER_TYPES)[number];
34
+ /**
35
+ * True when the provider resolves pre-uploaded file ids. Every other provider — the integration-backed
36
+ * and user-defined ones, which report no vendor identity of their own — ignores `fileIds` outright, so
37
+ * for them the ids are inert rather than wrong.
38
+ */
39
+ export declare function isFileCapableProviderType(type: AiProviderType): type is AiFileProviderType;
28
40
  /**
29
41
  * Public OpenAI chat model names (active models only).
30
42
  * @category AI
31
43
  */
32
- export declare const OPENAI_CHAT_MODEL_NAMES: readonly ["gpt-5.4-mini", "gpt-5.4-nano", "gpt-5.5", "gpt-5.5-pro", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna"];
44
+ export declare const OPENAI_CHAT_MODEL_NAMES: readonly ["gpt-5.5-pro", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna"];
33
45
  /**
34
46
  * Public Gemini chat model names (active models only).
35
47
  * @category AI
36
48
  */
37
- export declare const GEMINI_CHAT_MODEL_NAMES: readonly ["gemini-3.1-pro", "gemini-3.6-flash", "gemini-3.5-flash-lite"];
49
+ export declare const GEMINI_CHAT_MODEL_NAMES: readonly ["gemini-3.1-pro", "gemini-3.7-flash", "gemini-3.5-flash-lite"];
38
50
  /**
39
51
  * Public Grok chat model names (active models only).
40
52
  * @category AI
41
53
  */
42
- export declare const GROK_CHAT_MODEL_NAMES: readonly ["grok-4.5", "grok-4-1-fast-reasoning", "grok-4-1-fast-non-reasoning"];
54
+ export declare const GROK_CHAT_MODEL_NAMES: readonly ["grok-4.6", "grok-4-1-fast-reasoning", "grok-4-1-fast-non-reasoning"];
43
55
  /**
44
56
  * Public Anthropic chat model names (active models only).
45
57
  * @category AI
46
58
  */
47
- export declare const ANTHROPIC_CHAT_MODEL_NAMES: readonly ["claude-fable-5", "claude-haiku-4-5-20251001", "claude-opus-5", "claude-sonnet-5"];
59
+ export declare const ANTHROPIC_CHAT_MODEL_NAMES: readonly ["claude-fable-5", "claude-fable-5-1", "claude-haiku-4-5-20251001", "claude-opus-5", "claude-sonnet-5"];
48
60
  /**
49
61
  * The supported AI model names.
50
62
  * @category AI
51
63
  */
52
- export declare const VENDOR_AI_CHAT_MODEL_NAMES: readonly ["gpt-5.4-mini", "gpt-5.4-nano", "gpt-5.5", "gpt-5.5-pro", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "claude-fable-5", "claude-haiku-4-5-20251001", "claude-opus-5", "claude-sonnet-5", "gemini-3.1-pro", "gemini-3.6-flash", "gemini-3.5-flash-lite", "grok-4.5", "grok-4-1-fast-reasoning", "grok-4-1-fast-non-reasoning"];
64
+ export declare const VENDOR_AI_CHAT_MODEL_NAMES: readonly ["gpt-5.5-pro", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "claude-fable-5", "claude-fable-5-1", "claude-haiku-4-5-20251001", "claude-opus-5", "claude-sonnet-5", "gemini-3.1-pro", "gemini-3.7-flash", "gemini-3.5-flash-lite", "grok-4.6", "grok-4-1-fast-reasoning", "grok-4-1-fast-non-reasoning"];
53
65
  /** Checks if the given model name is a global AI chat model name. */
54
66
  export declare function isVendorAiChatModelName(modelName: unknown): modelName is VendorAiChatModelName;
55
67
  /**
@@ -59,7 +71,7 @@ export declare const OPENAI_EMBEDDINGS_MODEL_NAMES: readonly ["text-embedding-3-
59
71
  /**
60
72
  * @category AI
61
73
  */
62
- export declare const VOYAGE_EMBEDDING_MODEL_NAMES: readonly ["voyage-3-large"];
74
+ export declare const VOYAGE_EMBEDDING_MODEL_NAMES: readonly ["voyage-3-large", "voyage-4-large", "voyage-4"];
63
75
  /**
64
76
  * @category AI
65
77
  */
@@ -67,7 +79,7 @@ export declare const BEDROCK_EMBEDDING_MODEL_NAMES: readonly ["titan-embed-text-
67
79
  /**
68
80
  * @category AI
69
81
  */
70
- export declare const AI_EMBEDDINGS_MODEL_NAMES: readonly ["text-embedding-3-small", "voyage-3-large", "titan-embed-text-v2"];
82
+ export declare const AI_EMBEDDINGS_MODEL_NAMES: readonly ["text-embedding-3-small", "voyage-3-large", "voyage-4-large", "voyage-4", "titan-embed-text-v2"];
71
83
  /**
72
84
  * Checks if the given model name is a valid AI embeddings model name.
73
85
  * @category AI