@squidcloud/client 1.0.470 → 1.0.472
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 +9 -0
- package/dist/internal-common/src/public-types/ai-knowledge-base.public-types.d.ts +27 -44
- package/dist/internal-common/src/public-types/event.public-types.d.ts +18 -0
- package/dist/internal-common/src/public-types/extraction.public-types.d.ts +33 -0
- package/dist/internal-common/src/public-types/metadata-filter.public-types.d.ts +85 -0
- package/dist/internal-common/src/public-types/metric.public-types.d.ts +23 -3
- package/dist/typescript-client/src/agent/ai-agent-client-reference.d.ts +6 -0
- package/dist/typescript-client/src/agent/ai-agent-client.d.ts +1 -0
- package/dist/typescript-client/src/ai-client.d.ts +1 -0
- package/dist/typescript-client/src/events-client.d.ts +21 -0
- package/dist/typescript-client/src/index.d.ts +1 -0
- package/dist/typescript-client/src/public-types.d.ts +1 -0
- package/dist/typescript-client/src/squid.d.ts +15 -0
- package/dist/typescript-client/src/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -473,6 +473,15 @@ export interface BaseAiChatOptions {
|
|
|
473
473
|
executionPlanOptions?: AiAgentExecutionPlanOptions;
|
|
474
474
|
/** An array of file URLs to include in the chat context. */
|
|
475
475
|
fileUrls?: Array<AiFileUrl>;
|
|
476
|
+
/**
|
|
477
|
+
* Arbitrary client-defined annotations attached to this AI call for usage tracking.
|
|
478
|
+
* Reported as `annotation.<key>` tags on Squid AI usage metrics, so token usage can later be
|
|
479
|
+
* filtered and grouped by these values (e.g. `{ feature: 'support-bot', requestSource: 'mobile' }`).
|
|
480
|
+
* Inherited by nested calls to connected agents made while serving this call.
|
|
481
|
+
* Limits: at most 10 entries, keys up to 64 characters, values up to 256 characters;
|
|
482
|
+
* entries beyond the limits are dropped or truncated.
|
|
483
|
+
*/
|
|
484
|
+
metricAnnotations?: Record<string, string>;
|
|
476
485
|
/**
|
|
477
486
|
* The level of reasoning effort to apply; defaults to model-specific value.
|
|
478
487
|
* Effective only for models with reasoning.
|
|
@@ -2,6 +2,7 @@ import { AgentContextRequest, AiChatModelSelection, UpsertContextStatusError } f
|
|
|
2
2
|
import { AiEmbeddingsModelSelection, AiRerankProvider } from './ai-common.public-types';
|
|
3
3
|
import { AiContextId, AiKnowledgeBaseId, AppId } from './communication.public-types';
|
|
4
4
|
import { DocumentExtractionMethod } from './extraction.public-types';
|
|
5
|
+
import { MetadataAndFilter, MetadataFieldFilter, MetadataFilter, MetadataOrFilter, MetadataSimpleFilter, MetadataValue, MetadataValueArray } from './metadata-filter.public-types';
|
|
5
6
|
/**
|
|
6
7
|
* The set of supported vector store backends for a knowledge base. The authoritative backend for a
|
|
7
8
|
* given KB is persisted on its record; reads/writes route through the matching vector provider.
|
|
@@ -39,7 +40,11 @@ export interface AiKnowledgeBase {
|
|
|
39
40
|
export interface AiKnowledgeBaseMetadataField {
|
|
40
41
|
/** The name of field.*/
|
|
41
42
|
name: string;
|
|
42
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* The field data type - used for validation and filtering. `date` values are normalized to integer
|
|
45
|
+
* epoch milliseconds at write time so range filters (`$gt`/`$lt`) work across vector store backends.
|
|
46
|
+
* `array` is not yet supported and is rejected at knowledge-base upsert time.
|
|
47
|
+
*/
|
|
43
48
|
dataType: 'string' | 'number' | 'boolean' | 'date' | 'array';
|
|
44
49
|
/** Indicates if the field is required for knowledge base entries.*/
|
|
45
50
|
required: boolean;
|
|
@@ -57,67 +62,37 @@ export interface AiKnowledgeBaseMetadataField {
|
|
|
57
62
|
export type AiContextMetadata = Record<string, AiContextMetadataValue>;
|
|
58
63
|
/**
|
|
59
64
|
* @category AI
|
|
65
|
+
* @deprecated Use {@link MetadataValue} from `metadata-filter.public-types` instead.
|
|
60
66
|
*/
|
|
61
|
-
export type AiContextMetadataValue =
|
|
67
|
+
export type AiContextMetadataValue = MetadataValue;
|
|
62
68
|
/**
|
|
63
69
|
* @category AI
|
|
70
|
+
* @deprecated Use {@link MetadataValueArray} from `metadata-filter.public-types` instead.
|
|
64
71
|
*/
|
|
65
|
-
export type AiContextMetadataValueArray =
|
|
66
|
-
interface AiContextMetadataEqFilter {
|
|
67
|
-
$eq: AiContextMetadataValue;
|
|
68
|
-
}
|
|
69
|
-
interface AiContextMetadataNeFilter {
|
|
70
|
-
$ne: AiContextMetadataValue;
|
|
71
|
-
}
|
|
72
|
-
interface AiContextMetadataGtFilter {
|
|
73
|
-
$gt: number;
|
|
74
|
-
}
|
|
75
|
-
interface AiContextMetadataGteFilter {
|
|
76
|
-
$gte: number;
|
|
77
|
-
}
|
|
78
|
-
interface AiContextMetadataLtFilter {
|
|
79
|
-
$lt: number;
|
|
80
|
-
}
|
|
81
|
-
interface AiContextMetadataLteFilter {
|
|
82
|
-
$lte: number;
|
|
83
|
-
}
|
|
84
|
-
interface AiContextMetadataInFilter {
|
|
85
|
-
$in: AiContextMetadataValueArray;
|
|
86
|
-
}
|
|
87
|
-
interface AiContextMetadataNinFilter {
|
|
88
|
-
$nin: AiContextMetadataValueArray;
|
|
89
|
-
}
|
|
90
|
-
interface AiContextMetadataExistsFilter {
|
|
91
|
-
$exists: boolean;
|
|
92
|
-
}
|
|
72
|
+
export type AiContextMetadataValueArray = MetadataValueArray;
|
|
93
73
|
/**
|
|
94
74
|
* @category AI
|
|
75
|
+
* @deprecated Use {@link MetadataSimpleFilter} from `metadata-filter.public-types` instead.
|
|
95
76
|
*/
|
|
96
|
-
export type AiContextMetadataSimpleFilter =
|
|
77
|
+
export type AiContextMetadataSimpleFilter = MetadataSimpleFilter;
|
|
97
78
|
/**
|
|
98
79
|
* A filter for AI context metadata based on field-specific conditions or values.
|
|
99
80
|
* @category AI
|
|
81
|
+
* @deprecated Use {@link MetadataFieldFilter} from `metadata-filter.public-types` instead.
|
|
100
82
|
*/
|
|
101
|
-
export
|
|
102
|
-
/** A record where keys are field names and values are either simple filters or direct metadata values. */
|
|
103
|
-
[field: string]: AiContextMetadataSimpleFilter | AiContextMetadataValue;
|
|
104
|
-
}
|
|
83
|
+
export type AiContextMetadataFieldFilter = MetadataFieldFilter;
|
|
105
84
|
/**
|
|
106
85
|
* A filter combining multiple AI context metadata filters with a logical AND operation.
|
|
107
86
|
* @category AI
|
|
87
|
+
* @deprecated Use {@link MetadataAndFilter} from `metadata-filter.public-types` instead.
|
|
108
88
|
*/
|
|
109
|
-
export
|
|
110
|
-
/** An array of filters that must all be true for the condition to pass. */
|
|
111
|
-
$and: AiContextMetadataFilter[];
|
|
112
|
-
}
|
|
89
|
+
export type AiContextMetadataAndFilter = MetadataAndFilter;
|
|
113
90
|
/**
|
|
114
91
|
* A filter combining multiple AI context metadata filters with a logical OR operation.
|
|
115
92
|
* @category AI
|
|
93
|
+
* @deprecated Use {@link MetadataOrFilter} from `metadata-filter.public-types` instead.
|
|
116
94
|
*/
|
|
117
|
-
export
|
|
118
|
-
/** An array of filters where at least one must be true for the condition to pass. */
|
|
119
|
-
$or: AiContextMetadataFilter[];
|
|
120
|
-
}
|
|
95
|
+
export type AiContextMetadataOrFilter = MetadataOrFilter;
|
|
121
96
|
/**
|
|
122
97
|
* The options for the AI knowledgebase search method.
|
|
123
98
|
* @category AI
|
|
@@ -167,8 +142,9 @@ export interface AiHybridSearchWeights {
|
|
|
167
142
|
}
|
|
168
143
|
/**
|
|
169
144
|
* @category AI
|
|
145
|
+
* @deprecated Use {@link MetadataFilter} from `metadata-filter.public-types` instead.
|
|
170
146
|
*/
|
|
171
|
-
export type AiContextMetadataFilter =
|
|
147
|
+
export type AiContextMetadataFilter = MetadataFilter;
|
|
172
148
|
/**
|
|
173
149
|
* Represents an AI knowledge base's context entry with metadata and content.
|
|
174
150
|
* @category AI
|
|
@@ -196,6 +172,13 @@ export interface AiKnowledgeBaseContext {
|
|
|
196
172
|
sizeBytes: number;
|
|
197
173
|
/** Metadata associated with the context. */
|
|
198
174
|
metadata: AiContextMetadata;
|
|
175
|
+
/**
|
|
176
|
+
* Names of metadata fields whose stored values were machine-extracted from the content
|
|
177
|
+
* (driven by the knowledge base's `metadataFields` schema) rather than user-supplied.
|
|
178
|
+
* On re-upsert/replay, extracted values count as not-supplied (re-extracted fresh) while
|
|
179
|
+
* user-supplied values are preserved; consumers can also use this to caveat extracted values.
|
|
180
|
+
*/
|
|
181
|
+
autoExtractedMetadataFields?: string[];
|
|
199
182
|
/** Original request configuration for how the context content was processed. */
|
|
200
183
|
requestConfig?: AgentContextRequest;
|
|
201
184
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A generic event that can be emitted with `squid.events().emit` and handled by one or more
|
|
3
|
+
* subscribers declared with the backend `@eventHandler` decorator. Events are delivered over core's
|
|
4
|
+
* internal event stream (not the public queue API), at-least-once and with no ordering guarantee.
|
|
5
|
+
*/
|
|
6
|
+
export interface TriggerEvent<T = unknown> {
|
|
7
|
+
/** Unique event id (e.g. `generateUUID()`). */
|
|
8
|
+
id: string;
|
|
9
|
+
/** The event type. Determines which `@eventHandler` subscribers receive the event. */
|
|
10
|
+
type: string;
|
|
11
|
+
/** Arbitrary, JSON-serializable event payload. */
|
|
12
|
+
payload: T;
|
|
13
|
+
}
|
|
14
|
+
/** Request body for the `events/emit` core endpoint that publishes a `TriggerEvent`. */
|
|
15
|
+
export interface EmitEventRequest<T = unknown> {
|
|
16
|
+
/** The event to emit. */
|
|
17
|
+
event: TriggerEvent<T>;
|
|
18
|
+
}
|
|
@@ -35,6 +35,15 @@ export interface ExtractDataFromDocumentOptions {
|
|
|
35
35
|
* the content. Only consulted by extractors that handle text input.
|
|
36
36
|
*/
|
|
37
37
|
textFormat?: 'auto' | 'markdown' | 'html' | 'plain';
|
|
38
|
+
/**
|
|
39
|
+
* Whether to read document-level properties (title/author/dates) from the source container and
|
|
40
|
+
* return them as `documentMetadata`. Off by default: container parsing has a real per-file cost
|
|
41
|
+
* (zip/PDF re-parse), so callers opt in only when the owning knowledge base declares metadata fields.
|
|
42
|
+
*
|
|
43
|
+
* Honored only by file-based extraction (which owns the original buffer for every format);
|
|
44
|
+
* URL-based extraction ignores it and never returns `documentMetadata`.
|
|
45
|
+
*/
|
|
46
|
+
collectDocumentMetadata?: boolean;
|
|
38
47
|
}
|
|
39
48
|
/**
|
|
40
49
|
* Request payload for extracting data from a document via URL.
|
|
@@ -108,6 +117,11 @@ export interface ExtractDataFromDocumentResponse {
|
|
|
108
117
|
* Path to the original file in cloud storage, if applicable.
|
|
109
118
|
*/
|
|
110
119
|
longTermStoragePath?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Document-level metadata extracted from the source container (best-effort). Present only when the
|
|
122
|
+
* extractor was able to read it.
|
|
123
|
+
*/
|
|
124
|
+
documentMetadata?: DocumentMetadata;
|
|
111
125
|
}
|
|
112
126
|
/**
|
|
113
127
|
* Create PDF request type.
|
|
@@ -186,3 +200,22 @@ export interface CreatePdfResponse {
|
|
|
186
200
|
/** The generated filename. */
|
|
187
201
|
fileName?: string;
|
|
188
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Document-level properties read from the source container during extraction. Every field is optional
|
|
205
|
+
* and best-effort: when a container does not expose a property (or parsing fails) the field is simply
|
|
206
|
+
* absent. Consumed by schema-driven metadata extraction as the deterministic source for matching
|
|
207
|
+
* knowledge-base `metadataFields` before falling back to LLM extraction.
|
|
208
|
+
* @category AI
|
|
209
|
+
*/
|
|
210
|
+
export interface DocumentMetadata {
|
|
211
|
+
/** Document title (e.g. OOXML `dc:title`, PDF `/Title`, front-matter `title`, `<title>`). */
|
|
212
|
+
docTitle?: string;
|
|
213
|
+
/** Document author (e.g. OOXML `dc:creator`, PDF `/Author`, front-matter / `<meta author>`). */
|
|
214
|
+
docAuthor?: string;
|
|
215
|
+
/** Creation timestamp, ISO 8601. */
|
|
216
|
+
docCreatedAt?: string;
|
|
217
|
+
/** Last-modified timestamp, ISO 8601. */
|
|
218
|
+
docModifiedAt?: string;
|
|
219
|
+
/** Source document type: `pdf` | `docx` | `pptx` | `xlsx` | `md` | `html` | `txt`. */
|
|
220
|
+
docType?: string;
|
|
221
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic metadata filter types used across the platform.
|
|
3
|
+
*
|
|
4
|
+
* These types define a MongoDB-style filter syntax for filtering records by metadata
|
|
5
|
+
* fields. They support field-level operators (`$eq`, `$ne`, `$gt`, `$gte`, `$lt`,
|
|
6
|
+
* `$lte`, `$in`, `$nin`, `$exists`) and boolean combinators (`$and`, `$or`).
|
|
7
|
+
*
|
|
8
|
+
* Originally created for AI knowledge base context filtering, these types are now
|
|
9
|
+
* shared across metrics tag filtering, matchmaking, and other subsystems.
|
|
10
|
+
*/
|
|
11
|
+
/** Primitive metadata value. */
|
|
12
|
+
export type MetadataValue = number | string | boolean | undefined;
|
|
13
|
+
/** Array of metadata values (used by `$in` / `$nin`). */
|
|
14
|
+
export type MetadataValueArray = MetadataValue[];
|
|
15
|
+
interface MetadataEqFilter {
|
|
16
|
+
$eq: MetadataValue;
|
|
17
|
+
}
|
|
18
|
+
interface MetadataNeFilter {
|
|
19
|
+
$ne: MetadataValue;
|
|
20
|
+
}
|
|
21
|
+
interface MetadataGtFilter {
|
|
22
|
+
$gt: number;
|
|
23
|
+
}
|
|
24
|
+
interface MetadataGteFilter {
|
|
25
|
+
$gte: number;
|
|
26
|
+
}
|
|
27
|
+
interface MetadataLtFilter {
|
|
28
|
+
$lt: number;
|
|
29
|
+
}
|
|
30
|
+
interface MetadataLteFilter {
|
|
31
|
+
$lte: number;
|
|
32
|
+
}
|
|
33
|
+
interface MetadataInFilter {
|
|
34
|
+
$in: MetadataValueArray;
|
|
35
|
+
}
|
|
36
|
+
interface MetadataNinFilter {
|
|
37
|
+
$nin: MetadataValueArray;
|
|
38
|
+
}
|
|
39
|
+
interface MetadataExistsFilter {
|
|
40
|
+
$exists: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** A single-field operator: one of `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`, `$in`, `$nin`, `$exists`. */
|
|
43
|
+
export type MetadataSimpleFilter = MetadataEqFilter | MetadataNeFilter | MetadataGtFilter | MetadataGteFilter | MetadataLtFilter | MetadataLteFilter | MetadataInFilter | MetadataNinFilter | MetadataExistsFilter;
|
|
44
|
+
/**
|
|
45
|
+
* A filter for metadata based on field-specific conditions or direct values.
|
|
46
|
+
* @category Metadata
|
|
47
|
+
*/
|
|
48
|
+
export interface MetadataFieldFilter {
|
|
49
|
+
/** A record where keys are field names and values are either operator objects or direct scalar values. */
|
|
50
|
+
[field: string]: MetadataSimpleFilter | MetadataValue;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A filter combining multiple metadata filters with a logical AND operation.
|
|
54
|
+
* @category Metadata
|
|
55
|
+
*/
|
|
56
|
+
export interface MetadataAndFilter {
|
|
57
|
+
/** An array of filters that must all be true for the condition to pass. */
|
|
58
|
+
$and: MetadataFilter[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A filter combining multiple metadata filters with a logical OR operation.
|
|
62
|
+
* @category Metadata
|
|
63
|
+
*/
|
|
64
|
+
export interface MetadataOrFilter {
|
|
65
|
+
/** An array of filters where at least one must be true for the condition to pass. */
|
|
66
|
+
$or: MetadataFilter[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A composable metadata filter supporting field operators and boolean combinators.
|
|
70
|
+
*
|
|
71
|
+
* @example Simple equality
|
|
72
|
+
* ```ts
|
|
73
|
+
* { status: 'active' }
|
|
74
|
+
* ```
|
|
75
|
+
* @example Operators
|
|
76
|
+
* ```ts
|
|
77
|
+
* { age: { $gte: 18 }, role: { $in: ['admin', 'editor'] } }
|
|
78
|
+
* ```
|
|
79
|
+
* @example Boolean combinators
|
|
80
|
+
* ```ts
|
|
81
|
+
* { $or: [{ status: 'active' }, { role: { $ne: 'guest' } }] }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export type MetadataFilter = MetadataFieldFilter | MetadataAndFilter | MetadataOrFilter;
|
|
85
|
+
export {};
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import { MetadataFilter } from './metadata-filter.public-types';
|
|
2
|
+
/**
|
|
3
|
+
* Tag filter for metric queries. Accepts either a simple key-value record (backward compatible)
|
|
4
|
+
* or the full {@link MetadataFilter} tree with `$eq`, `$ne`, `$in`, `$nin`, `$exists`,
|
|
5
|
+
* `$gt`, `$gte`, `$lt`, `$lte`, `$and`, `$or`.
|
|
6
|
+
* @category Metrics
|
|
7
|
+
*/
|
|
8
|
+
export type MetricTagFilter = Record<string, string> | MetadataFilter;
|
|
1
9
|
/**
|
|
2
10
|
* Name of metrics publicly provided by the system.
|
|
3
11
|
* - Metrics suffixed by '_time' are 'gauge' metrics.
|
|
@@ -49,10 +57,22 @@ export interface QueryMetricsRequestCommon {
|
|
|
49
57
|
*/
|
|
50
58
|
fillValue?: number | null;
|
|
51
59
|
/**
|
|
52
|
-
* Tag filters.
|
|
53
|
-
*
|
|
60
|
+
* Tag filters. Supports two formats:
|
|
61
|
+
* - Simple: `Record<string, string>` — each key-value pair is an exact equality match.
|
|
62
|
+
* - Advanced: `AiContextMetadataFilter` — the same filter syntax used by AI knowledge base
|
|
63
|
+
* metadata, supporting `$eq`, `$ne`, `$in`, `$nin`, `$exists`, `$and`, `$or`, and
|
|
64
|
+
* comparison operators (`$gt`, `$gte`, `$lt`, `$lte` — numeric comparisons on string tags).
|
|
65
|
+
*
|
|
66
|
+
* @example Simple format
|
|
67
|
+
* ```ts
|
|
68
|
+
* tagFilter: { aiModel: 'claude-sonnet-4-5-20250514', isError: '0' }
|
|
69
|
+
* ```
|
|
70
|
+
* @example Advanced format
|
|
71
|
+
* ```ts
|
|
72
|
+
* tagFilter: { $or: [{ aiModel: { $in: ['claude-sonnet-4-5-20250514', 'gpt-4o'] } }, { isError: { $ne: '0' } }] }
|
|
73
|
+
* ```
|
|
54
74
|
*/
|
|
55
|
-
tagFilter?:
|
|
75
|
+
tagFilter?: MetricTagFilter;
|
|
56
76
|
/**
|
|
57
77
|
* A mapping of known tag values that must be present in the response groups.
|
|
58
78
|
*
|
|
@@ -23,6 +23,7 @@ export declare class AiAgentReference {
|
|
|
23
23
|
private readonly socketManager;
|
|
24
24
|
private readonly jobClient;
|
|
25
25
|
private readonly backendFunctionManager;
|
|
26
|
+
private readonly getMetricAnnotations;
|
|
26
27
|
/**
|
|
27
28
|
* Retrieves metadata and configuration of the AI agent.
|
|
28
29
|
*/
|
|
@@ -238,6 +239,11 @@ export declare class AiAgentReference {
|
|
|
238
239
|
private replaceFileTags;
|
|
239
240
|
private askInternal;
|
|
240
241
|
private chatInternal;
|
|
242
|
+
/**
|
|
243
|
+
* Merges the Squid-instance-level metric annotations under the per-call ones.
|
|
244
|
+
* Returns the options unchanged when no annotations are set anywhere.
|
|
245
|
+
*/
|
|
246
|
+
private withMetricAnnotations;
|
|
241
247
|
/**
|
|
242
248
|
* Calls rpcManager post but with the agent api key if one was given during construction
|
|
243
249
|
*/
|
|
@@ -22,6 +22,7 @@ export declare class AiAgentClient {
|
|
|
22
22
|
private readonly socketManager;
|
|
23
23
|
private readonly jobClient;
|
|
24
24
|
private readonly backendFunctionManager;
|
|
25
|
+
private readonly getMetricAnnotations;
|
|
25
26
|
private readonly ongoingChatSequences;
|
|
26
27
|
/**
|
|
27
28
|
* Retrieves an instance of AiAgentReference for a specific agent ID.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TriggerEvent } from '../../internal-common/src/public-types/event.public-types';
|
|
2
|
+
/**
|
|
3
|
+
* EventsClient provides methods for emitting generic events that are handled by backend functions
|
|
4
|
+
* declared with the `@eventHandler` decorator.
|
|
5
|
+
* @category Platform
|
|
6
|
+
*/
|
|
7
|
+
export declare class EventsClient {
|
|
8
|
+
private readonly rpcManager;
|
|
9
|
+
/**
|
|
10
|
+
* Emits a generic event delivered to every subscriber declared with `@eventHandler` for the same
|
|
11
|
+
* event type. Events are delivered durably/at-least-once with no ordering guarantee, so handlers
|
|
12
|
+
* should be idempotent and order-independent. Resolves once the event is enqueued, not once
|
|
13
|
+
* subscribers have handled it.
|
|
14
|
+
*
|
|
15
|
+
* Requires API key authentication — events are emitted only by trusted server-side code, so calls
|
|
16
|
+
* authenticated with a user token are rejected.
|
|
17
|
+
*
|
|
18
|
+
* @param event The event to emit, with a unique `id`, a `type`, and a `payload`.
|
|
19
|
+
*/
|
|
20
|
+
emit<T>(event: TriggerEvent<T>): Promise<void>;
|
|
21
|
+
}
|
|
@@ -25,6 +25,7 @@ export * from './document-identity.service';
|
|
|
25
25
|
export * from './document-reference';
|
|
26
26
|
export * from './document-reference.factory';
|
|
27
27
|
export * from './document-store';
|
|
28
|
+
export * from './events-client';
|
|
28
29
|
export * from './execute-function-options';
|
|
29
30
|
export * from './external-auth-client';
|
|
30
31
|
export * from './extraction-client';
|
|
@@ -13,6 +13,7 @@ export * from '../../internal-common/src/public-types/code-executor.public-types
|
|
|
13
13
|
export * from '../../internal-common/src/public-types/communication.public-types';
|
|
14
14
|
export * from '../../internal-common/src/public-types/context.public-types';
|
|
15
15
|
export * from '../../internal-common/src/public-types/document.public-types';
|
|
16
|
+
export * from '../../internal-common/src/public-types/event.public-types';
|
|
16
17
|
export * from '../../internal-common/src/public-types/external-auth/external-auth.public-types';
|
|
17
18
|
export * from '../../internal-common/src/public-types/extraction.public-types';
|
|
18
19
|
export * from '../../internal-common/src/public-types/http-status.public-types';
|
|
@@ -4,6 +4,7 @@ import { ApiClient } from './api-client';
|
|
|
4
4
|
import { CollectionReference } from './collection-reference';
|
|
5
5
|
import { ConnectionDetails } from './connection-details';
|
|
6
6
|
import { DistributedLock, DistributedLockOptions } from './distributed-lock.manager';
|
|
7
|
+
import { EventsClient } from './events-client';
|
|
7
8
|
import { ExecuteFunctionOptions } from './execute-function-options';
|
|
8
9
|
import { ExternalAuthClient } from './external-auth-client';
|
|
9
10
|
import { ExtractionClient } from './extraction-client';
|
|
@@ -129,8 +130,10 @@ export declare class Squid {
|
|
|
129
130
|
private readonly queueManagerFactory;
|
|
130
131
|
private readonly schedulerClient;
|
|
131
132
|
private readonly notificationClient;
|
|
133
|
+
private readonly eventsClient;
|
|
132
134
|
private readonly _appId;
|
|
133
135
|
private readonly runtimeOptions;
|
|
136
|
+
private metricAnnotations?;
|
|
134
137
|
/**
|
|
135
138
|
* Creates a new instance of Squid with the given options.
|
|
136
139
|
*
|
|
@@ -314,6 +317,14 @@ export declare class Squid {
|
|
|
314
317
|
* Returns a set of AI specific clients.
|
|
315
318
|
*/
|
|
316
319
|
ai(): AiClient;
|
|
320
|
+
/**
|
|
321
|
+
* Sets default metric annotations attached to every AI call made through this Squid instance.
|
|
322
|
+
* Annotations are reported as `annotation.<key>` tags on Squid AI usage metrics, so token usage
|
|
323
|
+
* can later be filtered and grouped by them (e.g. `{ feature: 'support-bot' }`).
|
|
324
|
+
* Per-call `metricAnnotations` in chat options are merged on top of these defaults.
|
|
325
|
+
* Pass `undefined` to clear. See `BaseAiChatOptions.metricAnnotations` for limits.
|
|
326
|
+
*/
|
|
327
|
+
setMetricAnnotations(annotations: Record<string, string> | undefined): void;
|
|
317
328
|
/**
|
|
318
329
|
* Returns a set of functionality for interacting with jobs.
|
|
319
330
|
*/
|
|
@@ -350,6 +361,10 @@ export declare class Squid {
|
|
|
350
361
|
* Returns a client for working with structured data extraction tools.
|
|
351
362
|
*/
|
|
352
363
|
extraction(): ExtractionClient;
|
|
364
|
+
/**
|
|
365
|
+
* Returns a client for emitting events handled by `@eventHandler` backend functions.
|
|
366
|
+
*/
|
|
367
|
+
events(): EventsClient;
|
|
353
368
|
/**
|
|
354
369
|
* Returns a distributed lock for the given mutex. The lock can be used to synchronize access to a shared resource.
|
|
355
370
|
* The lock will be released when the release method on the returned object is invoked or whenever the connection
|