@xpert-ai/contracts 3.17.1 → 3.17.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpert-ai/contracts",
3
- "version": "3.17.1",
3
+ "version": "3.17.2",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@octokit/types": "13.10.0",
23
23
  "@types/json-schema": "^7.0.15",
24
- "@xpert-ai/chatkit-types": "~0.4.6",
24
+ "@xpert-ai/chatkit-types": "~0.5.0",
25
25
  "zod-to-json-schema": "^3.25.2"
26
26
  },
27
27
  "types": "./index.d.ts"
@@ -1,7 +1,11 @@
1
+ import type { LLMPriceAuthority, LLMPriceBreakdownItem } from '../ai/ai-model.model';
2
+ import type { ModelUsagePricingStatus } from '../ai/model-usage.model';
1
3
  export type TTokenUsage = {
2
4
  promptTokens: number;
3
5
  completionTokens: number;
4
6
  totalTokens: number;
7
+ cacheReadInputTokens?: number;
8
+ cacheWriteInputTokens?: number;
5
9
  };
6
10
  export interface IModelUsage {
7
11
  totalTokens: number;
@@ -18,4 +22,9 @@ export interface ILLMUsage extends IModelUsage {
18
22
  completionUnitPrice: number;
19
23
  completionPriceUnit: number;
20
24
  completionPrice: number;
25
+ cacheReadInputTokens?: number;
26
+ cacheWriteInputTokens?: number;
27
+ pricingStatus?: ModelUsagePricingStatus;
28
+ priceAuthority?: LLMPriceAuthority;
29
+ pricingBreakdown?: LLMPriceBreakdownItem[];
21
30
  }
@@ -2,7 +2,7 @@ import { AiModelTypeEnum } from '../agent/index';
2
2
  import { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
3
3
  import { I18nObject } from '../types';
4
4
  import { ICopilot } from './copilot.model';
5
- import type { ModelUsagePricingConfig } from './model-usage.model';
5
+ import type { ModelUsagePricingConfig, ModelUsagePricingStatus } from './model-usage.model';
6
6
  export interface IAiModel extends IBasePerTenantAndOrganizationEntityModel {
7
7
  /**
8
8
  * Model name
@@ -177,12 +177,88 @@ export interface PriceTierConfig {
177
177
  output?: number;
178
178
  max_tokens: number;
179
179
  }
180
+ export type LLMPriceComponent = 'input' | 'output' | 'cache_read_input' | 'cache_write_input' | 'request' | 'cache_storage';
181
+ export type LLMPriceAddOn = 'web_search' | 'grounding';
182
+ export type LLMCacheWriteTtl = '5m' | '1h';
183
+ export interface LLMPriceRule {
184
+ component: LLMPriceComponent;
185
+ unit_price: number;
186
+ unit_size: number;
187
+ currency?: string;
188
+ min_input_tokens?: number;
189
+ max_input_tokens?: number;
190
+ min_output_tokens?: number;
191
+ max_output_tokens?: number;
192
+ mode?: string;
193
+ region?: string;
194
+ service_tier?: string;
195
+ add_on?: LLMPriceAddOn;
196
+ cache_ttl?: LLMCacheWriteTtl;
197
+ daily_time_window?: ModelPriceDailyTimeWindow;
198
+ }
199
+ export interface LLMPriceAddOnUsage {
200
+ type: LLMPriceAddOn;
201
+ quantity: number;
202
+ }
203
+ export interface LLMUnpricedAddOnUsage extends LLMPriceAddOnUsage {
204
+ authority: 'request';
205
+ }
206
+ export type LLMPriceAuthority = 'catalog' | 'provider';
207
+ export interface ModelPriceDailyTimeWindow {
208
+ /** IANA time zone, for example Asia/Shanghai. */
209
+ time_zone: string;
210
+ /** Inclusive local wall-clock time in HH:mm or HH:mm:ss format. */
211
+ start_time: string;
212
+ /** Exclusive local wall-clock time in HH:mm or HH:mm:ss format. */
213
+ end_time: string;
214
+ }
215
+ export interface LLMReportedPrice {
216
+ amount: number;
217
+ currency: string;
218
+ }
219
+ export interface LLMPriceContext {
220
+ mode?: string;
221
+ region?: string;
222
+ serviceTier?: string;
223
+ cacheWriteTtl?: LLMCacheWriteTtl;
224
+ /** Provider-reported cache write token counts when one response contains multiple TTLs. */
225
+ cacheWriteInputTokensByTtl?: Partial<Record<LLMCacheWriteTtl, number>>;
226
+ /** Whether promptTokens already includes cache read and write tokens. */
227
+ inputTokensIncludeCache?: boolean;
228
+ addOns?: LLMPriceAddOnUsage[];
229
+ /** Requested add-ons whose actual provider usage is unavailable in the response. */
230
+ unpricedAddOns?: LLMUnpricedAddOnUsage[];
231
+ /** Stored cache volume multiplied by storage duration in hours. */
232
+ cacheStorageTokenHours?: number;
233
+ /** Wall-clock instant used to select recurring price windows. */
234
+ pricingTime?: Date | string;
235
+ }
236
+ export interface LLMPriceBreakdownItem {
237
+ component: LLMPriceComponent;
238
+ quantity: number;
239
+ pricingStatus: ModelUsagePricingStatus;
240
+ unitPrice?: number;
241
+ unit?: number;
242
+ amount?: number;
243
+ currency?: string;
244
+ addOn?: LLMPriceAddOn;
245
+ addOnAuthority?: LLMUnpricedAddOnUsage['authority'];
246
+ cacheTtl?: LLMCacheWriteTtl;
247
+ rule?: LLMPriceRule;
248
+ }
249
+ export interface LLMPriceCalculation {
250
+ pricingStatus: ModelUsagePricingStatus;
251
+ totalAmount: number;
252
+ currency: string;
253
+ breakdown: LLMPriceBreakdownItem[];
254
+ }
180
255
  export interface PriceConfig {
181
256
  input: number;
182
257
  output?: number;
183
258
  unit: number;
184
259
  currency: string;
185
260
  tiered_pricing?: PriceTierConfig[];
261
+ rules?: LLMPriceRule[];
186
262
  }
187
263
  export interface AIModelEntity extends ProviderModel {
188
264
  parameter_rules?: ParameterRule[];
@@ -34,9 +34,29 @@ export type DocumentTextParserConfig = DocumentParserConfig & {
34
34
  chunkSize?: number | null;
35
35
  chunkOverlap?: number | null;
36
36
  };
37
+ export type SpreadsheetInterpretation = 'records' | 'form_document';
38
+ export type SpreadsheetContextUnit = 'row' | 'sheet' | 'workbook';
39
+ export type SpreadsheetOversizePolicy = 'sheet' | 'reject';
40
+ export type SpreadsheetOutputFormat = 'anchored_markdown';
41
+ /**
42
+ * Spreadsheet-specific behavior used by the platform default parser.
43
+ * Custom document transformers take precedence over this configuration.
44
+ */
45
+ export type DocumentSpreadsheetParserConfig = {
46
+ interpretation?: SpreadsheetInterpretation;
47
+ contextUnit?: SpreadsheetContextUnit;
48
+ oversizePolicy?: SpreadsheetOversizePolicy;
49
+ maxChunkTokens?: number;
50
+ includeSheets?: string[];
51
+ includeHiddenSheets?: boolean;
52
+ preserveMergedCells?: boolean;
53
+ emitCellAnchors?: boolean;
54
+ outputFormat?: SpreadsheetOutputFormat;
55
+ };
37
56
  export type DocumentSheetParserConfig = DocumentParserConfig & {
38
57
  fields?: string[];
39
58
  indexedFields?: string[];
59
+ spreadsheet?: DocumentSpreadsheetParserConfig;
40
60
  };
41
61
  /**
42
62
  * Import Type:
@@ -168,7 +188,7 @@ export type TKnowledgeDocument = {
168
188
  * @deprecated unused
169
189
  */
170
190
  parserId: string;
171
- parserConfig: DocumentTextParserConfig;
191
+ parserConfig: DocumentTextParserConfig & Partial<DocumentSheetParserConfig>;
172
192
  /**
173
193
  * where dose this document come from
174
194
  */
@@ -3,7 +3,8 @@ import { IUser } from '../user.model';
3
3
  import { AiModelTypeEnum } from '../agent';
4
4
  import { ModelAccessSourceEnum } from './model-access.model';
5
5
  import { ModelGatewayUsageChannelEnum } from './model-gateway.model';
6
- import type { ModelUsageMetric, ModelUsageLedgerModality, ModelUsageLedgerOperation, ModelUsageOriginType, ModelUsagePriceRule, ModelUsagePricingStatus } from './model-usage.model';
6
+ import type { LLMPriceAuthority, LLMPriceBreakdownItem } from './ai-model.model';
7
+ import type { ModelUsageMetric, ModelUsageMetricComponent, ModelUsageLedgerModality, ModelUsageLedgerOperation, ModelUsageOriginType, ModelUsagePriceRule, ModelUsagePricingDimensions, ModelUsagePricingStatus } from './model-usage.model';
7
8
  export declare enum MembershipPlanStatusEnum {
8
9
  Active = "active",
9
10
  Archived = "archived"
@@ -183,6 +184,9 @@ export interface IMembershipPointLedger extends IBasePerTenantEntityModel {
183
184
  toolName?: string | null;
184
185
  modality?: ModelUsageLedgerModality | null;
185
186
  operation?: ModelUsageLedgerOperation | null;
187
+ metricKey?: string | null;
188
+ component?: ModelUsageMetricComponent | null;
189
+ pricingDimensions?: ModelUsagePricingDimensions | null;
186
190
  unit?: ModelUsageMetric['unit'] | null;
187
191
  authority?: ModelUsageMetric['authority'] | null;
188
192
  quantity?: number | null;
@@ -198,7 +202,9 @@ export interface IMembershipPointLedger extends IBasePerTenantEntityModel {
198
202
  unitPrice?: number | null;
199
203
  priceCurrency?: string | null;
200
204
  priceAmount?: number | null;
205
+ priceAuthority?: LLMPriceAuthority | null;
201
206
  pricingRule?: ModelUsagePriceRule | null;
207
+ pricingBreakdown?: LLMPriceBreakdownItem[] | null;
202
208
  chargedAt?: Date | string | null;
203
209
  settlementCurrency?: string | null;
204
210
  settlementAmount?: number | null;
@@ -1,11 +1,12 @@
1
1
  import type { IBasePerTenantAndOrganizationEntityModel } from '../base-entity.model';
2
2
  import type { AiModelTypeEnum } from '../agent';
3
- export type ModelUsageModality = 'image' | 'video';
4
- export type ModelUsageLedgerModality = 'text' | ModelUsageModality;
3
+ import type { LLMPriceAuthority, LLMPriceBreakdownItem, ModelPriceDailyTimeWindow } from './ai-model.model';
4
+ export type ModelUsageModality = 'text' | 'audio' | 'image' | 'video';
5
+ export type ModelUsageLedgerModality = ModelUsageModality;
5
6
  export type ImageGenerationOperation = 'text_to_image' | 'image_to_image' | 'multi_image_to_image';
6
7
  export type VideoGenerationOperation = 'text_to_video' | 'image_to_video' | 'first_last_frame_to_video' | 'reference_to_video';
7
- export type ModelUsageOperation = ImageGenerationOperation | VideoGenerationOperation;
8
- export type ModelUsageLedgerOperation = AiModelTypeEnum | ModelUsageOperation;
8
+ export type ModelUsageOperation = AiModelTypeEnum | ImageGenerationOperation | VideoGenerationOperation;
9
+ export type ModelUsageLedgerOperation = ModelUsageOperation;
9
10
  export type ModelUsageOriginType = 'execution' | 'tool' | 'model';
10
11
  export type ModelUsagePricingDimensions = {
11
12
  resolution?: string;
@@ -17,6 +18,7 @@ export type ModelUsagePricingDimensions = {
17
18
  export type ModelUsagePricingStatus = 'priced' | 'free' | 'unpriced';
18
19
  export type ModelUsageChargeType = 'paid' | 'free';
19
20
  export type ModelUsageTokenType = 'prompt' | 'completion' | 'total';
21
+ export type ModelUsageMetricComponent = 'input' | 'output' | 'request';
20
22
  export type ModelUsagePriceRule = {
21
23
  id: string;
22
24
  version: string;
@@ -28,8 +30,10 @@ export type ModelUsagePriceRule = {
28
30
  unit_price?: number;
29
31
  currency?: string;
30
32
  charge_type: ModelUsageChargeType;
33
+ component?: ModelUsageMetricComponent;
31
34
  operations?: ModelUsageOperation[];
32
35
  dimensions?: Partial<Omit<ModelUsagePricingDimensions, 'durationSeconds'>>;
36
+ daily_time_window?: ModelPriceDailyTimeWindow;
33
37
  source_url?: string;
34
38
  };
35
39
  export type ModelUsagePricingConfig = {
@@ -45,9 +49,16 @@ export type ModelUsagePricingContext = {
45
49
  };
46
50
  export type ModelUsagePricingSnapshot = {
47
51
  capturedAt: string;
52
+ pricingDimensions?: ModelUsagePricingDimensions;
48
53
  rules: ModelUsagePriceRule[];
49
54
  };
50
- export type ModelUsageMetric = {
55
+ export type ModelUsageMetricQualifiers = {
56
+ /** Stable identity inside one request. Required when component and unit are not unique. */
57
+ key?: string;
58
+ component?: ModelUsageMetricComponent;
59
+ pricingDimensions?: ModelUsagePricingDimensions;
60
+ };
61
+ export type ModelUsageMetric = ModelUsageMetricQualifiers & ({
51
62
  unit: 'token';
52
63
  promptTokens?: number;
53
64
  completionTokens?: number;
@@ -61,7 +72,15 @@ export type ModelUsageMetric = {
61
72
  unit: 'second';
62
73
  quantity: number;
63
74
  authority: 'provider' | 'request';
64
- };
75
+ } | {
76
+ unit: 'character';
77
+ quantity: number;
78
+ authority: 'provider' | 'request';
79
+ } | {
80
+ unit: 'request';
81
+ quantity: number;
82
+ authority: 'provider' | 'contract';
83
+ });
65
84
  /** Final, authoritative usage emitted after a model request has completed. */
66
85
  export type ModelUsageReport = {
67
86
  requestId: string;
@@ -96,6 +115,9 @@ export interface IModelUsageLedger extends IBasePerTenantAndOrganizationEntityMo
96
115
  toolName?: string | null;
97
116
  modality: ModelUsageLedgerModality;
98
117
  operation: ModelUsageLedgerOperation;
118
+ metricKey: string;
119
+ component?: ModelUsageMetricComponent | null;
120
+ pricingDimensions?: ModelUsagePricingDimensions | null;
99
121
  unit: ModelUsageMetric['unit'];
100
122
  authority: ModelUsageMetric['authority'];
101
123
  quantity?: number | null;
@@ -129,7 +151,9 @@ export interface IModelChargeLedger extends IBasePerTenantAndOrganizationEntityM
129
151
  unitPrice?: number | null;
130
152
  currency?: string | null;
131
153
  amount?: number | null;
154
+ priceAuthority?: LLMPriceAuthority | null;
132
155
  pricingRule?: ModelUsagePriceRule | null;
156
+ pricingBreakdown?: LLMPriceBreakdownItem[] | null;
133
157
  chargedAt: Date;
134
158
  settlementCurrency?: string | null;
135
159
  settlementAmount?: number | null;
@@ -249,7 +249,41 @@ export type TXpertWorkbenchOptions = {
249
249
  /** Public extension view key selected when the Workbench first loads. */
250
250
  defaultViewKey?: string;
251
251
  };
252
+ /**
253
+ * Stable lineage for an Xpert created or updated from an Assistant template.
254
+ * `templateId` is the canonical lookup key. Plugin templates use
255
+ * `<plugin package>:<template key>` so a later sync resolves the same provider.
256
+ */
257
+ export type TXpertTemplateSource = {
258
+ templateId: string;
259
+ templateKey: string;
260
+ pluginName?: string;
261
+ pluginDisplayName?: string;
262
+ source?: 'builtin' | 'plugin' | string;
263
+ installedAt?: string;
264
+ lastSyncedAt?: string;
265
+ releaseNotes?: string;
266
+ };
267
+ export type TXpertTemplateSyncResult = {
268
+ xpertId: string;
269
+ templateSource: TXpertTemplateSource;
270
+ templateTitle: string;
271
+ releaseNotes?: string;
272
+ };
273
+ export type TXpertDataXpertOptions = {
274
+ managedBy?: string;
275
+ templateKey?: string;
276
+ requiredPlugin?: string;
277
+ requiredPlugins?: string[];
278
+ [key: string]: unknown;
279
+ };
252
280
  export type TXpertOptions = {
281
+ /** Legacy template key retained for existing plugin-authored DSL files. */
282
+ templateKey?: string;
283
+ /** Legacy Agentic App descriptor retained for backward-compatible source discovery. */
284
+ dataXpert?: TXpertDataXpertOptions;
285
+ /** Canonical source used by Studio's update-from-template operation. */
286
+ templateSource?: TXpertTemplateSource;
253
287
  bootstrap?: {
254
288
  source: 'template';
255
289
  templateKey: string;
@@ -298,6 +298,14 @@ export interface WorkbenchNavigationOpenPayload {
298
298
  knowledgebaseId?: string;
299
299
  documentId?: string;
300
300
  parentId?: string;
301
+ /** Exact KnowledgeDocument chunk anchor for evidence navigation. */
302
+ chunkId?: string;
303
+ /** One-based source page anchor when the document has an analysis preview. */
304
+ page?: number;
305
+ /** Parser/OCR block anchors within the source page. */
306
+ sourceBlockIds?: string[];
307
+ /** Transient source excerpt used for context/highlighting; the host must not place it in the URL. */
308
+ evidenceText?: string;
301
309
  conversationId?: string;
302
310
  threadId?: string;
303
311
  executionId?: string;