@squidcloud/client 1.0.493 → 1.0.494
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.
- package/dist/cjs/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +13 -0
- package/dist/internal-common/src/public-types/ai-query.public-types.d.ts +12 -0
- package/dist/internal-common/src/types/headers.types.d.ts +6 -0
- package/dist/internal-common/src/utils/http-utils.d.ts +15 -0
- package/dist/internal-common/src/utils/integration-access-tokens.d.ts +15 -0
- package/dist/typescript-client/src/agent/ai-agent-client-reference.d.ts +1 -1
- package/dist/typescript-client/src/agent/ai-agent-client.types.d.ts +4 -4
- package/dist/typescript-client/src/ai-client.d.ts +4 -3
- package/dist/typescript-client/src/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
@@ -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
|
|
@@ -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
|
|
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 {
|
|
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?:
|
|
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,
|