@applica-software-guru/persona-sdk 0.1.114 → 0.1.116

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/index.d.ts CHANGED
@@ -117,6 +117,45 @@ export declare interface AgentValue {
117
117
  initialContext?: Record<string, unknown>;
118
118
  }
119
119
 
120
+ /** Prefix of a model name that references a model alias. */
121
+ export declare const ALIAS_PREFIX = "alias:";
122
+
123
+ /** Agents referencing an alias; also the detail of the 409 returned when deleting one in use. */
124
+ export declare interface AliasImpact {
125
+ aliasId: string;
126
+ aliasName: string;
127
+ /** May exceed `usages.length` when the list is capped. */
128
+ total: number;
129
+ usages: AliasUsage[];
130
+ }
131
+
132
+ /** `"alias:smart"` -> `"smart"`. Throws when `modelName` is not a reference. */
133
+ export declare function aliasNameFromRef(modelName: string): string;
134
+
135
+ /** `"smart"` -> `"alias:smart"`, to set as the `modelName` of an agent. */
136
+ export declare function aliasRef(name: string): string;
137
+
138
+ /** A proposal only: nothing is applied, the alias is edited by hand. */
139
+ export declare interface AliasSuggestions {
140
+ aliasId?: string | null;
141
+ /** The model the suggestions are measured against (the alias' target by default). */
142
+ referenceModel: string;
143
+ /** null when the registry does not know the reference model (e.g. already retired). */
144
+ reference?: ModelProfile | null;
145
+ notes: string[];
146
+ replacements: ModelSuggestion[];
147
+ fallbacks: ModelSuggestion[];
148
+ }
149
+
150
+ /** An agent that references an alias, and in which model slots. */
151
+ export declare interface AliasUsage {
152
+ agentId: string;
153
+ agentName?: string | null;
154
+ projectId?: string | null;
155
+ /** `model`, `compaction`, `loopRecovery`, `attachmentsPreprocessor`, `knowledge`. */
156
+ usedIn: string[];
157
+ }
158
+
120
159
  export declare class ApiException extends Error {
121
160
  readonly statusCode: number;
122
161
  readonly body: string;
@@ -246,7 +285,7 @@ export declare class BillingClient {
246
285
  listInvoices(owner: string, dateFrom?: string, dateTo?: string): Promise<Invoice[]>;
247
286
  cancelSubscription(owner: string): Promise<Subscription>;
248
287
  getUsageStats(projectId: string, dateFrom?: string, dateTo?: string, models?: string[]): Promise<UsageStats>;
249
- listUsages(projectId: string, dateFrom?: string, dateTo?: string, models?: string[], sessionId?: string, page?: number, size?: number): Promise<UsagePage>;
288
+ listUsages(projectId: string, dateFrom?: string, dateTo?: string, models?: string[], sessionId?: string, page?: number, size?: number, aliases?: string[]): Promise<UsagePage>;
250
289
  }
251
290
 
252
291
  export declare interface BillingUsage {
@@ -322,6 +361,22 @@ export declare class ChannelsApi extends HttpApi {
322
361
 
323
362
  export declare type ChannelStatus = 'active' | 'incomplete' | 'disconnected';
324
363
 
364
+ export declare interface ChoiceAnswer {
365
+ type: 'choice';
366
+ /** The winning option key. */
367
+ choice: string;
368
+ probabilities: Record<string, number>;
369
+ /** Normalized entropy (0-1), not the winning probability. */
370
+ confidence: number;
371
+ }
372
+
373
+ /** One of the options: `criteria` maps option keys to their descriptions. */
374
+ export declare interface ChoiceQuestion {
375
+ type: 'choice';
376
+ instructions: string | Record<string, unknown> | unknown[];
377
+ criteria: Record<string, string | null>;
378
+ }
379
+
325
380
  export declare interface ChunkResult {
326
381
  id?: string;
327
382
  text?: string;
@@ -445,6 +500,63 @@ export declare interface Customer {
445
500
  stripeCustomerId?: string;
446
501
  }
447
502
 
503
+ export declare type DecisionAnswer = NoulAnswer | ChoiceAnswer | ScoreAnswer | RefusalAnswer;
504
+
505
+ export declare interface DecisionModelInfo {
506
+ id: string;
507
+ provider: string;
508
+ maxInputTokens?: number | null;
509
+ inputCostPerToken?: number | null;
510
+ outputCostPerToken?: number | null;
511
+ }
512
+
513
+ export declare type DecisionQuestion = NoulQuestion | ChoiceQuestion | ScoreQuestion;
514
+
515
+ /**
516
+ * Decisions: typed questions about a state, answered with probabilities by a decision
517
+ * model (TypeSafe Jev, Cloudflare Clef). Mirrors `POST /decisions` of persona-core.
518
+ */
519
+ export declare type DecisionQuestionType = 'noul' | 'choice' | 'score' | 'box';
520
+
521
+ export declare interface DecisionRequest {
522
+ /** `"<provider>/<model>"` (e.g. `typesafe/jev-latest`) or `alias:<name>`. */
523
+ model: string;
524
+ /** What to decide about: text, an object or a list. */
525
+ state: unknown;
526
+ questions: Record<string, DecisionQuestion>;
527
+ /** Trace: code of the session the decision is stored in. */
528
+ sessionCode?: string;
529
+ /** Trace: parent session (e.g. a workflow execution). */
530
+ parentSessionId?: string;
531
+ userId?: string;
532
+ }
533
+
534
+ export declare interface DecisionResponse {
535
+ sessionId: string;
536
+ sessionCode: string;
537
+ /** The resolved model version that answered (e.g. `jev-1.14.0`). */
538
+ model: string;
539
+ answers: Record<string, DecisionAnswer>;
540
+ usage: DecisionUsage;
541
+ }
542
+
543
+ /**
544
+ * Decisions: typed questions about a state, answered with probabilities by a decision
545
+ * model (TypeSafe Jev, Cloudflare Clef). Stateless, no agent: each call is traced as a
546
+ * session and billed to the project.
547
+ */
548
+ export declare class DecisionsApi extends HttpApi {
549
+ constructor(baseUrl: string, auth: string | AuthenticationProvider);
550
+ decide(request: DecisionRequest): Promise<DecisionResponse>;
551
+ /** The decision models persona-core knows (`id` is what `decide` takes). */
552
+ listModels(): Promise<DecisionModelInfo[]>;
553
+ }
554
+
555
+ export declare interface DecisionUsage {
556
+ inputTokens: number;
557
+ outputTokens: number;
558
+ }
559
+
448
560
  export declare type DocumentExtractorName = 'fitz' | 'document-ai' | 'gemini' | 'markdown';
449
561
 
450
562
  export declare interface DowngradeSubscriptionRequest {
@@ -670,6 +782,9 @@ export declare interface Invoice {
670
782
  lines?: LineItem[];
671
783
  }
672
784
 
785
+ /** True when `modelName` is an `alias:<name>` reference. */
786
+ export declare function isAliasRef(modelName?: string | null): boolean;
787
+
673
788
  export declare interface KnowledgeBase {
674
789
  id?: string;
675
790
  projectId?: string;
@@ -876,8 +991,131 @@ export declare class MissionsApi extends HttpApi {
876
991
 
877
992
  export declare type MissionStatus = 'draft' | 'planned' | 'active' | 'review' | 'paused' | 'completed' | 'failed' | 'cancelled';
878
993
 
994
+ /**
995
+ * A named indirection to a concrete `<provider>/<model>`. An agent references it as
996
+ * `alias:<name>` (see {@link aliasRef}); editing the alias moves every agent using it.
997
+ */
998
+ export declare interface ModelAlias {
999
+ id: string;
1000
+ /** Lowercase slug used in `alias:<name>`. Immutable. */
1001
+ name: string;
1002
+ /** null => global (super admins only); set => per-project. Immutable. */
1003
+ projectId?: string | null;
1004
+ description?: string | null;
1005
+ /** Concrete litellm-style `<provider>/<model>`, never another alias. */
1006
+ target: string;
1007
+ /** Ordered alternatives, used at runtime when the target cannot serve a call. */
1008
+ fallbacks: string[];
1009
+ defaults: ModelAliasDefaults;
1010
+ /** Result of the last health check. Managed by the server. */
1011
+ health: ModelAliasHealth;
1012
+ /** Managed by the server. */
1013
+ history: ModelAliasChange[];
1014
+ createdAt?: string;
1015
+ updatedAt?: string;
1016
+ updatedBy?: string | null;
1017
+ }
1018
+
1019
+ /** Audit entry: one changed field of the alias (the last 50 are kept). */
1020
+ export declare interface ModelAliasChange {
1021
+ at: string;
1022
+ by?: string | null;
1023
+ field: 'target' | 'fallbacks' | 'defaults';
1024
+ old?: unknown;
1025
+ new?: unknown;
1026
+ }
1027
+
1028
+ /** Applied only to the fields an agent leaves empty. `temperature` is not here on purpose. */
1029
+ export declare interface ModelAliasDefaults {
1030
+ reasoningEffort?: ReasoningEffort | null;
1031
+ maxOutputTokens?: number | null;
1032
+ contextWindow?: number | null;
1033
+ }
1034
+
1035
+ /**
1036
+ * Model aliases: named indirections (`alias:<name>`) to a concrete model, with
1037
+ * ordered fallbacks. Global aliases are managed by super admins; project aliases by
1038
+ * super admins, project admins and the project API key (not plain users, nor agent
1039
+ * keys). Everyone in a project can read its aliases and the global ones.
1040
+ */
1041
+ export declare class ModelAliasesApi extends HttpApi {
1042
+ constructor(baseUrl: string, auth: string | AuthenticationProvider);
1043
+ /**
1044
+ * Aliases visible to the caller (their project's and the global ones). Super admins
1045
+ * can pass `projectId` to see another project's view.
1046
+ */
1047
+ list(projectId?: string | null, keyword?: string | null, page?: number, size?: number): Promise<Paginated<ModelAlias>>;
1048
+ get(id: string): Promise<ModelAlias>;
1049
+ /** Create an alias. Non-super-admins always create in their own project. */
1050
+ create(alias: ModelAliasInput): Promise<ModelAlias>;
1051
+ /** Change target, fallbacks, defaults and description. `name` and the scope are immutable. */
1052
+ update(id: string, alias: ModelAliasInput): Promise<ModelAlias>;
1053
+ /**
1054
+ * Delete an alias. Refused with a 409 while agents still reference it: use
1055
+ * {@link ModelAliasesApi.inUse} on the error to read which ones.
1056
+ */
1057
+ remove(id: string): Promise<void>;
1058
+ /** Agents that reference the alias, and in which model slot. */
1059
+ impact(id: string): Promise<AliasImpact>;
1060
+ /**
1061
+ * Run the health check now (registry, announced retirements, credentials). Stores the
1062
+ * result in `health` and updates the notifications; it never changes the alias.
1063
+ */
1064
+ check(id: string): Promise<ModelAlias>;
1065
+ /**
1066
+ * Replacement and fallback candidates for the alias' target, or for `model` (e.g. a
1067
+ * fallback that went missing). A proposal only: nothing is applied.
1068
+ */
1069
+ suggestions(id: string, model?: string | null, limit?: number): Promise<AliasSuggestions>;
1070
+ /**
1071
+ * The agents blocking a delete, when `error` is the 409 of {@link ModelAliasesApi.remove};
1072
+ * `null` for any other error.
1073
+ */
1074
+ static inUse(error: unknown): AliasImpact | null;
1075
+ }
1076
+
1077
+ export declare interface ModelAliasHealth {
1078
+ status: ModelAliasHealthStatus;
1079
+ checkedAt?: string | null;
1080
+ issues: ModelAliasIssue[];
1081
+ }
1082
+
1083
+ export declare type ModelAliasHealthStatus = 'unknown' | 'ok' | 'deprecating' | 'missing' | 'no_credentials';
1084
+
1085
+ /**
1086
+ * What to send to create or update an alias. The server-managed fields (`health`,
1087
+ * `history`, timestamps) are not part of it; `name` is required but immutable, and
1088
+ * the scope can only be chosen (via `projectId`) by super admins when creating.
1089
+ */
1090
+ export declare interface ModelAliasInput {
1091
+ name: string;
1092
+ target: string;
1093
+ projectId?: string | null;
1094
+ description?: string | null;
1095
+ fallbacks?: string[];
1096
+ defaults?: ModelAliasDefaults;
1097
+ }
1098
+
1099
+ /** A problem found by the health check on one of the alias' models. */
1100
+ export declare interface ModelAliasIssue {
1101
+ model: string;
1102
+ role: ModelAliasIssueRole;
1103
+ status: ModelAliasHealthStatus;
1104
+ detail?: string | null;
1105
+ /** Provider-announced retirement date (`YYYY-MM-DD`), when known. */
1106
+ deprecationDate?: string | null;
1107
+ }
1108
+
1109
+ export declare type ModelAliasIssueRole = 'target' | 'fallback';
1110
+
1111
+ export declare type ModelCapability = 'function_calling' | 'vision' | 'audio_input' | 'pdf_input' | 'reasoning';
1112
+
879
1113
  export declare interface ModelConfiguration {
880
- /** litellm-style "<provider>/<model>" string (e.g. "fireworks/accounts/fireworks/models/minimax-m3"). Use the known-models API for the current list. */
1114
+ /**
1115
+ * litellm-style "<provider>/<model>" string (e.g. "fireworks/accounts/fireworks/models/minimax-m3"), or a
1116
+ * model alias reference "alias:<name>" (see `aliasRef`), resolved by the server. Use the known-models API
1117
+ * for the current list.
1118
+ */
881
1119
  modelName?: string;
882
1120
  temperature?: number;
883
1121
  reasoningEffort?: ReasoningEffort;
@@ -903,8 +1141,26 @@ export declare interface ModelConfiguration {
903
1141
  openrouterModelName?: string;
904
1142
  }
905
1143
 
1144
+ /** What litellm's registry knows about a model. */
1145
+ export declare interface ModelProfile {
1146
+ model: string;
1147
+ contextWindow?: number | null;
1148
+ /** USD per million tokens. */
1149
+ inputCostPerMillion?: number | null;
1150
+ outputCostPerMillion?: number | null;
1151
+ capabilities: ModelCapability[];
1152
+ }
1153
+
906
1154
  export declare type ModelProvider = 'google' | 'openai' | 'grok' | 'fireworks' | 'together' | 'ollama' | 'openai_compatible' | 'openrouter';
907
1155
 
1156
+ /** A candidate to replace a model, or to add as a fallback. */
1157
+ export declare interface ModelSuggestion extends ModelProfile {
1158
+ provider: string;
1159
+ sameProvider: boolean;
1160
+ /** e.g. a smaller context window, a much higher price. */
1161
+ warnings: string[];
1162
+ }
1163
+
908
1164
  export declare interface NetworkConfiguration {
909
1165
  allowedWebsites?: string[];
910
1166
  allowedIps?: string[];
@@ -934,6 +1190,34 @@ export declare interface NodeExecutionResult {
934
1190
 
935
1191
  export declare type NodeType = 'start' | 'action' | 'condition' | 'loop' | 'tool' | 'agent' | 'set_var' | 'output' | 'workflow' | 'resource' | 'script';
936
1192
 
1193
+ /**
1194
+ * An in-platform notification (badge + banner). `title` and `message` are an English
1195
+ * fallback: clients localize from `code` and `data`.
1196
+ */
1197
+ declare interface Notification_2 {
1198
+ id: string;
1199
+ /** null => platform-wide, visible to super admins only. */
1200
+ projectId?: string | null;
1201
+ /** Producer area, e.g. `model_alias`. */
1202
+ type: string;
1203
+ /** Stable machine code, e.g. `model_alias.missing`, `model_alias.runtime_fallback`. */
1204
+ code: string;
1205
+ severity: NotificationSeverity;
1206
+ title: string;
1207
+ message: string;
1208
+ /** What it is about, for deep links. */
1209
+ entityType?: string | null;
1210
+ entityId?: string | null;
1211
+ dedupeKey?: string | null;
1212
+ data: Record<string, unknown>;
1213
+ createdAt?: string;
1214
+ readAt?: string | null;
1215
+ readBy?: string | null;
1216
+ /** Set when the problem it describes no longer applies. */
1217
+ resolvedAt?: string | null;
1218
+ }
1219
+ export { Notification_2 as Notification }
1220
+
937
1221
  /** A place where a project's human tasks are announced (e.g. a Telegram group). */
938
1222
  export declare interface NotificationChannel {
939
1223
  id: string;
@@ -951,6 +1235,50 @@ export declare interface NotificationChannel {
951
1235
  updatedAt?: string;
952
1236
  }
953
1237
 
1238
+ export declare interface NotificationListParams {
1239
+ /** Only the ones not read yet. */
1240
+ unreadOnly?: boolean;
1241
+ /** Include the ones whose problem is gone (hidden by default). */
1242
+ includeResolved?: boolean;
1243
+ /** Super admins: the view of this project (plus platform-wide ones). */
1244
+ projectId?: string | null;
1245
+ page?: number;
1246
+ size?: number;
1247
+ }
1248
+
1249
+ /**
1250
+ * In-platform notifications. A project sees its own; platform-wide ones (no project)
1251
+ * are for super admins. Agent API keys have no access. Read state is shared by
1252
+ * everyone who can see a notification.
1253
+ */
1254
+ export declare class NotificationsApi extends HttpApi {
1255
+ constructor(baseUrl: string, auth: string | AuthenticationProvider);
1256
+ list(params?: NotificationListParams): Promise<Paginated<Notification_2>>;
1257
+ /** Open, unread notifications: the value of the badge. */
1258
+ unreadCount(projectId?: string | null): Promise<number>;
1259
+ markRead(id: string): Promise<Notification_2>;
1260
+ /** Mark as read everything the caller can see. */
1261
+ markAllRead(projectId?: string | null): Promise<void>;
1262
+ }
1263
+
1264
+ export declare type NotificationSeverity = 'info' | 'warning' | 'critical';
1265
+
1266
+ export declare interface NoulAnswer {
1267
+ type: 'noul';
1268
+ /** Probability of yes (0-1). */
1269
+ noul: number;
1270
+ }
1271
+
1272
+ /** Yes/no question; `criteria` optionally describes the two sides. */
1273
+ export declare interface NoulQuestion {
1274
+ type: 'noul';
1275
+ instructions: string | Record<string, unknown> | unknown[];
1276
+ criteria?: {
1277
+ true?: string;
1278
+ false?: string;
1279
+ } | null;
1280
+ }
1281
+
954
1282
  export declare interface OAuth2CallbackResponse {
955
1283
  id?: string;
956
1284
  successUrl?: string;
@@ -1038,6 +1366,12 @@ export declare class PersonaSdk {
1038
1366
  missions(authProvider: AuthenticationProvider): MissionsApi;
1039
1367
  billing(apiKey: string): BillingClient;
1040
1368
  billing(authProvider: AuthenticationProvider): BillingClient;
1369
+ modelAliases(apiKey: string): ModelAliasesApi;
1370
+ modelAliases(authProvider: AuthenticationProvider): ModelAliasesApi;
1371
+ notifications(apiKey: string): NotificationsApi;
1372
+ notifications(authProvider: AuthenticationProvider): NotificationsApi;
1373
+ decisions(apiKey: string): DecisionsApi;
1374
+ decisions(authProvider: AuthenticationProvider): DecisionsApi;
1041
1375
  values(apiKey: string): ValuesApi;
1042
1376
  values(authProvider: AuthenticationProvider): ValuesApi;
1043
1377
  }
@@ -1150,13 +1484,17 @@ export declare class ProvidersApi extends HttpApi {
1150
1484
  models(provider: string): Promise<ProviderModel[]>;
1151
1485
  }
1152
1486
 
1153
- export declare type ReasoningEffort = 'minimal' | 'low' | 'medium' | 'high';
1487
+ export declare type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
1154
1488
 
1155
1489
  export declare interface Ref {
1156
1490
  nodeId?: string;
1157
1491
  variableName?: string;
1158
1492
  }
1159
1493
 
1494
+ export declare interface RefusalAnswer {
1495
+ type: 'refusal';
1496
+ }
1497
+
1160
1498
  export declare interface Revision {
1161
1499
  id?: string;
1162
1500
  entityId?: string;
@@ -1183,6 +1521,22 @@ export declare interface RunResult {
1183
1521
  nextNodes?: string[];
1184
1522
  }
1185
1523
 
1524
+ export declare interface ScoreAnswer {
1525
+ type: 'score';
1526
+ /** Expected zero-based level index (may be fractional). */
1527
+ score: number;
1528
+ probabilities: Record<string, number>;
1529
+ confidence: number;
1530
+ legend?: Record<string, unknown>;
1531
+ }
1532
+
1533
+ /** An ordered rubric: `criteria` lists the levels, lowest first (at least 2). */
1534
+ export declare interface ScoreQuestion {
1535
+ type: 'score';
1536
+ instructions: string | Record<string, unknown> | unknown[];
1537
+ criteria: string[];
1538
+ }
1539
+
1186
1540
  export declare interface SearchChunksRequest {
1187
1541
  query?: string;
1188
1542
  limit?: number;
@@ -1570,6 +1924,18 @@ export declare interface UpgradeSubscriptionRequest {
1570
1924
  toPlanType: string;
1571
1925
  }
1572
1926
 
1927
+ /**
1928
+ * Usage that went through a model alias. The cost is the sum over every concrete model
1929
+ * the alias served, so it follows the alias even when its target changes.
1930
+ */
1931
+ export declare interface UsageAliasEntry {
1932
+ alias: string;
1933
+ credits: number;
1934
+ count: number;
1935
+ totalCost?: number;
1936
+ totalPrice?: number;
1937
+ }
1938
+
1573
1939
  export declare interface UsageCost {
1574
1940
  service?: string;
1575
1941
  value?: number;
@@ -1577,6 +1943,8 @@ export declare interface UsageCost {
1577
1943
  price?: number;
1578
1944
  credits?: number;
1579
1945
  unit?: string;
1946
+ /** Name of the model alias the usage went through, if any. `service` names the concrete model that served it. */
1947
+ alias?: string | null;
1580
1948
  }
1581
1949
 
1582
1950
  export declare interface UsageDailyEntry {
@@ -1594,6 +1962,8 @@ export declare interface UsageDetail {
1594
1962
  price?: number;
1595
1963
  credits?: number;
1596
1964
  unit?: string;
1965
+ /** Name of the model alias the usage went through, if any. `service` names the concrete model that served it. */
1966
+ alias?: string | null;
1597
1967
  [key: string]: unknown;
1598
1968
  }
1599
1969
 
@@ -1618,6 +1988,8 @@ export declare interface UsageStats {
1618
1988
  totals: UsageTotals;
1619
1989
  daily: UsageDailyEntry[];
1620
1990
  byModel: UsageModelEntry[];
1991
+ /** Breakdown by model alias; empty (or absent on an older billing service) when none was used. */
1992
+ byAlias?: UsageAliasEntry[];
1621
1993
  availableModels: string[];
1622
1994
  hasCostData?: boolean;
1623
1995
  costDataMode?: 'actual' | 'estimated_price' | 'mixed' | 'none';
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@applica-software-guru/persona-sdk",
3
3
  "description": "Official TypeScript SDK for the Persona API — manage agents, sessions, projects, knowledge bases, workflows, triggers and more.",
4
4
  "private": false,
5
- "version": "0.1.114",
5
+ "version": "0.1.116",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "dev": "vite",
@@ -15,7 +15,7 @@ export type ToolType = 'remote' | 'local';
15
15
 
16
16
  export type CollaborationMode = 'delegate_and_return' | 'persistent_transfer' | 'consult_then_respond';
17
17
 
18
- export type ReasoningEffort = 'minimal' | 'low' | 'medium' | 'high';
18
+ export type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
19
19
 
20
20
  export type ModelProvider = 'google' | 'openai' | 'grok' | 'fireworks' | 'together' | 'ollama' | 'openai_compatible' | 'openrouter';
21
21
 
@@ -37,7 +37,11 @@ export interface Variable {
37
37
  }
38
38
 
39
39
  export interface ModelConfiguration {
40
- /** litellm-style "<provider>/<model>" string (e.g. "fireworks/accounts/fireworks/models/minimax-m3"). Use the known-models API for the current list. */
40
+ /**
41
+ * litellm-style "<provider>/<model>" string (e.g. "fireworks/accounts/fireworks/models/minimax-m3"), or a
42
+ * model alias reference "alias:<name>" (see `aliasRef`), resolved by the server. Use the known-models API
43
+ * for the current list.
44
+ */
41
45
  modelName?: string;
42
46
  temperature?: number;
43
47
  reasoningEffort?: ReasoningEffort;
@@ -168,6 +168,7 @@ export class BillingClient {
168
168
  sessionId?: string,
169
169
  page?: number,
170
170
  size?: number,
171
+ aliases?: string[],
171
172
  ): Promise<UsagePage> {
172
173
  const params: string[] = [];
173
174
  if (dateFrom) params.push('date_from=' + encodeURIComponent(dateFrom));
@@ -176,6 +177,8 @@ export class BillingClient {
176
177
  if (sessionId) params.push('session_id=' + encodeURIComponent(sessionId));
177
178
  if (page !== undefined) params.push('page=' + encodeURIComponent(String(page)));
178
179
  if (size !== undefined) params.push('size=' + encodeURIComponent(String(size)));
180
+ // usages with at least one line that went through one of these aliases
181
+ if (aliases?.length) aliases.forEach(a => params.push('alias=' + encodeURIComponent(a)));
179
182
  const query = params.length > 0 ? '?' + params.join('&') : '';
180
183
  return this.request<UsagePage>('/projects/' + projectId + '/subscription/usages' + query, 'GET');
181
184
  }
@@ -72,6 +72,8 @@ export interface UsageDetail {
72
72
  price?: number;
73
73
  credits?: number;
74
74
  unit?: string;
75
+ /** Name of the model alias the usage went through, if any. `service` names the concrete model that served it. */
76
+ alias?: string | null;
75
77
  [key: string]: unknown;
76
78
  }
77
79
 
@@ -142,6 +144,18 @@ export interface UsageModelEntry {
142
144
  totalPrice?: number;
143
145
  }
144
146
 
147
+ /**
148
+ * Usage that went through a model alias. The cost is the sum over every concrete model
149
+ * the alias served, so it follows the alias even when its target changes.
150
+ */
151
+ export interface UsageAliasEntry {
152
+ alias: string;
153
+ credits: number;
154
+ count: number;
155
+ totalCost?: number;
156
+ totalPrice?: number;
157
+ }
158
+
145
159
  export interface UsageTotals {
146
160
  creditsUsed: number;
147
161
  usageCount: number;
@@ -157,6 +171,8 @@ export interface UsageStats {
157
171
  totals: UsageTotals;
158
172
  daily: UsageDailyEntry[];
159
173
  byModel: UsageModelEntry[];
174
+ /** Breakdown by model alias; empty (or absent on an older billing service) when none was used. */
175
+ byAlias?: UsageAliasEntry[];
160
176
  availableModels: string[];
161
177
  hasCostData?: boolean;
162
178
  costDataMode?: 'actual' | 'estimated_price' | 'mixed' | 'none';
@@ -0,0 +1,23 @@
1
+ import { HttpApi } from '../http-api';
2
+ import { AuthenticationProvider } from '../auth/authentication-provider';
3
+ import { DecisionModelInfo, DecisionRequest, DecisionResponse } from './types';
4
+
5
+ /**
6
+ * Decisions: typed questions about a state, answered with probabilities by a decision
7
+ * model (TypeSafe Jev, Cloudflare Clef). Stateless, no agent: each call is traced as a
8
+ * session and billed to the project.
9
+ */
10
+ export class DecisionsApi extends HttpApi {
11
+ constructor(baseUrl: string, auth: string | AuthenticationProvider) {
12
+ super(baseUrl, auth);
13
+ }
14
+
15
+ async decide(request: DecisionRequest): Promise<DecisionResponse> {
16
+ return this.httpPost<DecisionResponse>('/decisions', request);
17
+ }
18
+
19
+ /** The decision models persona-core knows (`id` is what `decide` takes). */
20
+ async listModels(): Promise<DecisionModelInfo[]> {
21
+ return this.httpGet<DecisionModelInfo[]>('/decision-models');
22
+ }
23
+ }