@squidcloud/client 1.0.493 → 1.0.495

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.
@@ -781,6 +781,19 @@ export type AiChatOptions<T extends AiChatModelSelection | undefined = undefined
781
781
  export type AllAiAgentChatOptions = {
782
782
  [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);
783
783
  };
784
+ /**
785
+ * Credentials a caller sends with one chat request. The client sends them in the `x-squid-integration-access-tokens`
786
+ * request header rather than with the options, so they reach only the tools that run with them and are never stored
787
+ * with the agent.
788
+ * @category AI
789
+ */
790
+ export interface AiChatRequestCredentials {
791
+ /**
792
+ * Access tokens keyed by integration ID. The integration's tools run with its token for this request when the
793
+ * integration type supports it; other types ignore it.
794
+ */
795
+ integrationAccessTokens?: Record<IntegrationId, string>;
796
+ }
784
797
  /**
785
798
  * Configuration for exposing an AI agent as an MCP server at `/mcp/<agentId>`.
786
799
  * @category AI
@@ -1871,11 +1871,18 @@ export interface BulkIngestionFileStatus {
1871
1871
  * bytes exceed what the extraction provider accepts) and `'UNSUPPORTED_FILE_TYPE'`.
1872
1872
  * `'DUPLICATE_CONTENT'` is a skip rather than a failure: the KB already holds this content.
1873
1873
  * `'EXTRACTION_TIMED_OUT'` stays retryable — the deadline is contended, so a borderline document can
1874
- * cross it under load. `'JOB_FULL'`: the job's request ceiling had no room left for this file, so re-submit it
1875
- * in a fresh job; a file that alone exceeds the ceiling fails this way in every job. Additive; absent for
1876
- * ordinary failures.
1874
+ * cross it under load. So do `'SOURCE_UNREACHABLE'` (the provider could not fetch the source, which a
1875
+ * fresh link can fix) and `'PROVIDER_ACCESS_DENIED'` (the provider refused the credential or its quota is
1876
+ * spent, a fault of the environment). `'JOB_FULL'`: the job's request ceiling had no room left for this
1877
+ * file, so re-submit it in a fresh job; a file that alone exceeds the ceiling fails this way in every job.
1878
+ * Additive; absent for ordinary failures.
1877
1879
  */
1878
- errorCode?: 'CONTENT_TOO_LARGE' | 'DUPLICATE_CONTENT' | 'ENCRYPTED_DOCUMENT' | 'EXTRACTION_TIMED_OUT' | 'JOB_FULL' | 'NO_EMBEDDABLE_CONTENT' | 'SOURCE_OVER_PROVIDER_LIMIT' | 'UNSUPPORTED_FILE_TYPE';
1880
+ errorCode?: 'CONTENT_TOO_LARGE' | 'DUPLICATE_CONTENT' | 'ENCRYPTED_DOCUMENT' | 'EXTRACTION_TIMED_OUT' | 'JOB_FULL' | 'NO_EMBEDDABLE_CONTENT' | 'PROVIDER_ACCESS_DENIED' | 'SOURCE_OVER_PROVIDER_LIMIT' | 'SOURCE_UNREACHABLE' | 'UNSUPPORTED_FILE_TYPE';
1881
+ /**
1882
+ * Present only on a failed file an extraction provider answered: a stable fingerprint of that answer
1883
+ * (provider, HTTP status and provider code), so a caller can tell the same failure repeating from a new one.
1884
+ */
1885
+ errorSignature?: string;
1879
1886
  /**
1880
1887
  * Present only on a failed file: the same bytes fail the same way, so a caller must park the file
1881
1888
  * instead of re-submitting it. Absence means retryable.
@@ -39,6 +39,18 @@ export interface AiQueryOptions {
39
39
  /** Optional AI validation of generated queries. Can be used independently or with generateQueriesOnly. */
40
40
  validateWithAiOptions?: AiQueryValidateWithAiOptions;
41
41
  }
42
+ /**
43
+ * Options of a single AI query call: the query options plus a credential the client sends as a request header.
44
+ * @category AI
45
+ */
46
+ export interface AiQueryRequestOptions extends AiQueryOptions {
47
+ /**
48
+ * Access token the generated queries run with in place of the integration's stored secret, for integration
49
+ * types that support it. Other types ignore it. Sent in the `x-squid-integration-access-tokens` request header
50
+ * rather than with the options, so it is never stored.
51
+ */
52
+ accessToken?: string;
53
+ }
42
54
  /**
43
55
  * Request to execute an AI query using a specific integration.
44
56
  * Supports additional query execution options.
@@ -25,6 +25,12 @@ export declare const SquidHeaders: {
25
25
  readonly CLIENT_VERSION: "x-squid-client-version";
26
26
  /** Originating IP address of the request. */
27
27
  readonly SOURCE_IP: "x-squid-source-ip";
28
+ /**
29
+ * Access tokens the caller supplies for the request's integrations, as a JSON object keyed by
30
+ * integration ID. An integration type that runs with one takes it in place of its stored secret.
31
+ * The header stays in the cores and never reaches tenant code.
32
+ */
33
+ readonly INTEGRATION_ACCESS_TOKENS: "x-squid-integration-access-tokens";
28
34
  /**
29
35
  * Response-only: IP of the tenant pod that served the request, i.e. the address to reach it at
30
36
  * again. Core records it to route subsequent affinity-keyed calls to the same pod. Absent when the
@@ -6,6 +6,7 @@ export interface ObservableNameMetrics {
6
6
  }
7
7
  export declare const ObservableNames: {
8
8
  readonly nativeQuery: ObservableNameMetrics;
9
+ readonly registerQuery: ObservableNameMetrics;
9
10
  readonly query: ObservableNameMetrics;
10
11
  readonly mutate: ObservableNameMetrics;
11
12
  readonly functionExecution: ObservableNameMetrics;
@@ -0,0 +1,15 @@
1
+ import { ObjectAssertion } from 'assertic';
2
+ import { HttpStatusCode } from '../public-types/http-status.public-types';
3
+ export type HttpQueryParams = Record<string, string | number | boolean>;
4
+ /**
5
+ * Asserts that a value is truthy. Throws a {@link ValidationError} with the given HTTP status code if it is not.
6
+ * Narrows the type of `value` to exclude `null`, `undefined`, `false`, `0`, and `''`.
7
+ */
8
+ export declare function assertHttp<T>(value: T, message: string, status: HttpStatusCode): asserts value is NonNullable<T> & (T extends false | 0 | '' ? never : T);
9
+ /**
10
+ * Asserts that an object matches the given ObjectAssertion.
11
+ * Re-throws any non-ValidationError as BAD_REQUEST.
12
+ */
13
+ export declare function assertHttpInput<T>(value: T, assertion: ObjectAssertion<T>): asserts value is T;
14
+ /** Builds a query string from the record of key-value pairs. */
15
+ export declare function buildHttpQueryString(queryParams: HttpQueryParams): string;
@@ -0,0 +1,15 @@
1
+ import { AiChatRequestCredentials } from '../public-types/ai-agent.public-types';
2
+ import { IntegrationId } from '../public-types/communication.public-types';
3
+ /** Access tokens a caller supplies for one request, keyed by integration ID. */
4
+ export type IntegrationAccessTokens = Record<IntegrationId, string>;
5
+ /** Serializes [tokens] into the value of the {@link SquidHeaders.INTEGRATION_ACCESS_TOKENS} header. */
6
+ export declare function serializeIntegrationAccessTokens(tokens: IntegrationAccessTokens): string;
7
+ /** Parses the {@link SquidHeaders.INTEGRATION_ACCESS_TOKENS} header value; a malformed value is a bad request. */
8
+ export declare function parseIntegrationAccessTokens(headerValue: string): IntegrationAccessTokens;
9
+ /** Builds the request headers that carry [tokens]; empty when there is nothing to send. */
10
+ export declare function toIntegrationAccessTokenHeaders(tokens: IntegrationAccessTokens | undefined): Record<string, string>;
11
+ /** Splits the tokens off the call [options]: the headers that carry them, and the options the request body takes. */
12
+ export declare function splitIntegrationAccessTokens<T extends AiChatRequestCredentials>(options: T | undefined): {
13
+ headers: Record<string, string>;
14
+ options: Omit<T, 'integrationAccessTokens'> | undefined;
15
+ };
@@ -262,7 +262,7 @@ export declare class AiAgentReference {
262
262
  */
263
263
  private withMetricAnnotations;
264
264
  /**
265
- * Calls rpcManager post but with the agent api key if one was given during construction
265
+ * Calls rpcManager post with [headers], adding the agent api key if one was given during construction
266
266
  */
267
267
  private post;
268
268
  }
@@ -1,5 +1,5 @@
1
1
  import { Observable } from 'rxjs';
2
- import { AiAnnotation, AiChatModelSelection, AiChatOptions } from '../../../internal-common/src/public-types/ai-agent.public-types';
2
+ import { AiAnnotation, AiChatModelSelection, AiChatOptions, AiChatRequestCredentials } from '../../../internal-common/src/public-types/ai-agent.public-types';
3
3
  /**
4
4
  * Response format for transcribing audio and generating a chat response.
5
5
  * Contains the transcribed text and a stream of AI-generated responses.
@@ -51,18 +51,18 @@ export interface AskWithVoiceResponse {
51
51
  */
52
52
  export type AiChatOptionsWithoutVoice<T extends AiChatModelSelection | undefined = undefined> = Omit<AiChatOptions<T>, 'voiceOptions'> & {
53
53
  model?: T;
54
- };
54
+ } & AiChatRequestCredentials;
55
55
  /**
56
56
  * Options for AI-generated responses that exclude voice-specific settings and smooth typing behavior.
57
57
  * @category AI
58
58
  */
59
59
  export type AiAskOptions<T extends AiChatModelSelection | undefined = undefined> = Omit<AiChatOptions<T>, 'voiceOptions' | 'smoothTyping'> & {
60
60
  model?: T;
61
- };
61
+ } & AiChatRequestCredentials;
62
62
  /**
63
63
  * Options for AI-generated responses that include voice-specific settings but excludes smooth typing.
64
64
  * @category AI
65
65
  */
66
66
  export type AiAskOptionsWithVoice<T extends AiChatModelSelection | undefined = undefined> = Omit<AiChatOptions<T>, 'smoothTyping'> & {
67
67
  model?: T;
68
- };
68
+ } & AiChatRequestCredentials;
@@ -1,6 +1,6 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { AiFunctionMetadata } from '../../internal-common/src/public-types/ai-function.public-types';
3
- import { AiQueryOptions, AiQueryResponse, AiSpreadsheetQueryOptions, ExecuteAiApiResponse, ExecuteAiSpreadsheetQueryResponse } from '../../internal-common/src/public-types/ai-query.public-types';
3
+ import { AiQueryRequestOptions, AiQueryResponse, AiSpreadsheetQueryOptions, ExecuteAiApiResponse, ExecuteAiSpreadsheetQueryResponse } from '../../internal-common/src/public-types/ai-query.public-types';
4
4
  import { AiAgentClientOptions } from './agent/ai-agent-client';
5
5
  import { AiAgentReference } from './agent/ai-agent-client-reference';
6
6
  import { AiAudioClient } from './ai-audio-client';
@@ -102,7 +102,8 @@ export declare class AiClient {
102
102
  * @param prompt The text prompt to send to the AI. This should be formulated in a way that the AI can
103
103
  * understand and respond to, taking into account the nature of the task or the information
104
104
  * sought.
105
- * @param options Additional options to customize the query execution.
105
+ * @param options Additional options to customize the query execution. An `accessToken` is sent as a request
106
+ * header rather than with the options.
106
107
  * @param abortSignal Optional signal used to abort the underlying request. When the signal aborts, the in-flight
107
108
  * HTTP request is cancelled and its promise rejects, allowing callers to bound a single call
108
109
  * without leaking the request.
@@ -121,7 +122,7 @@ export declare class AiClient {
121
122
  * For more details on the usage and capabilities of the AI Assistant, refer to the documentation provided at
122
123
  * {@link https://docs.squid.cloud/docs/ai}.
123
124
  */
124
- executeAiQuery(integrationId: IntegrationId, prompt: string, options?: AiQueryOptions, abortSignal?: AbortSignal): Promise<AiQueryResponse>;
125
+ executeAiQuery(integrationId: IntegrationId, prompt: string, options?: AiQueryRequestOptions, abortSignal?: AbortSignal): Promise<AiQueryResponse>;
125
126
  /**
126
127
  * Executes an AI-powered API call using a specific integration.
127
128
  * The AI will select appropriate endpoints, generate request bodies,
@@ -18,6 +18,7 @@ export declare class DocumentReference<T extends DocumentData = any> {
18
18
  private readonly dataManager;
19
19
  private readonly queryBuilderFactory;
20
20
  private readonly projectFields?;
21
+ private readonly identityReference?;
21
22
  /** A string that uniquely identifies this document reference. */
22
23
  refId: string;
23
24
  /**
@@ -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.493";
5
+ export declare const SQUIDCLOUD_CLIENT_PACKAGE_VERSION = "1.0.495";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.493",
3
+ "version": "1.0.495",
4
4
  "description": "A typescript implementation of the Squid client",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",