@applica-software-guru/persona-sdk 0.1.113 → 0.1.115
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/README.md +86 -1
- package/dist/bundle.cjs.js +1 -1
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +468 -315
- package/dist/bundle.es.js.map +1 -1
- package/dist/index.d.ts +339 -3
- package/package.json +1 -1
- package/src/agents/types.ts +6 -2
- package/src/billing/billing-client.ts +3 -0
- package/src/billing/types.ts +16 -0
- package/src/index.ts +27 -0
- package/src/model-aliases/model-aliases-api.ts +94 -0
- package/src/model-aliases/references.ts +20 -0
- package/src/model-aliases/types.ts +125 -0
- package/src/notifications/notifications-api.ts +42 -0
- package/src/notifications/types.ts +39 -0
- package/src/persona-sdk.ts +14 -0
- package/src/sessions/types.ts +2 -0
- package/src/workflows/channels-api.ts +61 -0
- package/src/workflows/types.ts +45 -0
- package/src/workflows/workflows-api.ts +5 -0
- package/tests/billing-aliases.test.mjs +71 -0
- package/tests/channels-api.test.mjs +55 -0
- package/tests/model-aliases-api.test.mjs +198 -0
- package/tests/notifications-api.test.mjs +88 -0
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 {
|
|
@@ -267,6 +306,61 @@ export declare interface ChangeProjectSubscriptionPlanRequest {
|
|
|
267
306
|
toPlanType: string;
|
|
268
307
|
}
|
|
269
308
|
|
|
309
|
+
/** An external account linked to the current user. */
|
|
310
|
+
export declare interface ChannelIdentity {
|
|
311
|
+
id: string;
|
|
312
|
+
provider: string;
|
|
313
|
+
externalUserId: string;
|
|
314
|
+
externalUsername?: string;
|
|
315
|
+
iamUserId: string;
|
|
316
|
+
iamUserEmail?: string;
|
|
317
|
+
createdAt?: string;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** One-shot deep link completing a group or account link. */
|
|
321
|
+
export declare interface ChannelLink {
|
|
322
|
+
token: string;
|
|
323
|
+
url: string;
|
|
324
|
+
expiresAt: string;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export declare interface ChannelProvider {
|
|
328
|
+
provider: string;
|
|
329
|
+
botUsername?: string;
|
|
330
|
+
ready: boolean;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Notification channels: where the project's human tasks are announced and
|
|
335
|
+
* can be answered outside the inbox (a Telegram group, one message per
|
|
336
|
+
* task). Linking goes through one-shot deep links returned by the service.
|
|
337
|
+
* Identity endpoints require a user (IAM bearer) session. Lives on the
|
|
338
|
+
* workflows service.
|
|
339
|
+
*/
|
|
340
|
+
export declare class ChannelsApi extends HttpApi {
|
|
341
|
+
constructor(baseUrl: string, auth: string | AuthenticationProvider);
|
|
342
|
+
/** The providers enabled on the server (e.g. the Telegram bot). */
|
|
343
|
+
providers(): Promise<ChannelProvider[]>;
|
|
344
|
+
/** The project's channels, with their setup status. */
|
|
345
|
+
list(): Promise<NotificationChannel[]>;
|
|
346
|
+
/** One-shot deep link that links a group to the project. */
|
|
347
|
+
createLink(provider?: string): Promise<ChannelLink>;
|
|
348
|
+
update(channelId: string, changes: {
|
|
349
|
+
includePayload?: boolean;
|
|
350
|
+
locale?: string;
|
|
351
|
+
}): Promise<NotificationChannel>;
|
|
352
|
+
/** Re-checks the channel setup (the bot can still post in the group). */
|
|
353
|
+
verify(channelId: string): Promise<NotificationChannel>;
|
|
354
|
+
unlink(channelId: string): Promise<void>;
|
|
355
|
+
/** The caller's linked accounts. */
|
|
356
|
+
myIdentities(): Promise<ChannelIdentity[]>;
|
|
357
|
+
/** One-shot deep link that links the caller's account. */
|
|
358
|
+
createIdentityLink(provider?: string): Promise<ChannelLink>;
|
|
359
|
+
unlinkIdentity(provider?: string): Promise<void>;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export declare type ChannelStatus = 'active' | 'incomplete' | 'disconnected';
|
|
363
|
+
|
|
270
364
|
export declare interface ChunkResult {
|
|
271
365
|
id?: string;
|
|
272
366
|
text?: string;
|
|
@@ -549,6 +643,8 @@ export declare interface HumanTask {
|
|
|
549
643
|
origin?: 'node' | 'agent_escalation';
|
|
550
644
|
question?: string;
|
|
551
645
|
payload?: Record<string, unknown>;
|
|
646
|
+
/** Closed set of answers (buttons); absent = free-text answer. */
|
|
647
|
+
options?: string[];
|
|
552
648
|
assignee?: string;
|
|
553
649
|
role?: string;
|
|
554
650
|
status: string;
|
|
@@ -613,6 +709,9 @@ export declare interface Invoice {
|
|
|
613
709
|
lines?: LineItem[];
|
|
614
710
|
}
|
|
615
711
|
|
|
712
|
+
/** True when `modelName` is an `alias:<name>` reference. */
|
|
713
|
+
export declare function isAliasRef(modelName?: string | null): boolean;
|
|
714
|
+
|
|
616
715
|
export declare interface KnowledgeBase {
|
|
617
716
|
id?: string;
|
|
618
717
|
projectId?: string;
|
|
@@ -819,8 +918,131 @@ export declare class MissionsApi extends HttpApi {
|
|
|
819
918
|
|
|
820
919
|
export declare type MissionStatus = 'draft' | 'planned' | 'active' | 'review' | 'paused' | 'completed' | 'failed' | 'cancelled';
|
|
821
920
|
|
|
921
|
+
/**
|
|
922
|
+
* A named indirection to a concrete `<provider>/<model>`. An agent references it as
|
|
923
|
+
* `alias:<name>` (see {@link aliasRef}); editing the alias moves every agent using it.
|
|
924
|
+
*/
|
|
925
|
+
export declare interface ModelAlias {
|
|
926
|
+
id: string;
|
|
927
|
+
/** Lowercase slug used in `alias:<name>`. Immutable. */
|
|
928
|
+
name: string;
|
|
929
|
+
/** null => global (super admins only); set => per-project. Immutable. */
|
|
930
|
+
projectId?: string | null;
|
|
931
|
+
description?: string | null;
|
|
932
|
+
/** Concrete litellm-style `<provider>/<model>`, never another alias. */
|
|
933
|
+
target: string;
|
|
934
|
+
/** Ordered alternatives, used at runtime when the target cannot serve a call. */
|
|
935
|
+
fallbacks: string[];
|
|
936
|
+
defaults: ModelAliasDefaults;
|
|
937
|
+
/** Result of the last health check. Managed by the server. */
|
|
938
|
+
health: ModelAliasHealth;
|
|
939
|
+
/** Managed by the server. */
|
|
940
|
+
history: ModelAliasChange[];
|
|
941
|
+
createdAt?: string;
|
|
942
|
+
updatedAt?: string;
|
|
943
|
+
updatedBy?: string | null;
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
/** Audit entry: one changed field of the alias (the last 50 are kept). */
|
|
947
|
+
export declare interface ModelAliasChange {
|
|
948
|
+
at: string;
|
|
949
|
+
by?: string | null;
|
|
950
|
+
field: 'target' | 'fallbacks' | 'defaults';
|
|
951
|
+
old?: unknown;
|
|
952
|
+
new?: unknown;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/** Applied only to the fields an agent leaves empty. `temperature` is not here on purpose. */
|
|
956
|
+
export declare interface ModelAliasDefaults {
|
|
957
|
+
reasoningEffort?: ReasoningEffort | null;
|
|
958
|
+
maxOutputTokens?: number | null;
|
|
959
|
+
contextWindow?: number | null;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Model aliases: named indirections (`alias:<name>`) to a concrete model, with
|
|
964
|
+
* ordered fallbacks. Global aliases are managed by super admins; project aliases by
|
|
965
|
+
* super admins, project admins and the project API key (not plain users, nor agent
|
|
966
|
+
* keys). Everyone in a project can read its aliases and the global ones.
|
|
967
|
+
*/
|
|
968
|
+
export declare class ModelAliasesApi extends HttpApi {
|
|
969
|
+
constructor(baseUrl: string, auth: string | AuthenticationProvider);
|
|
970
|
+
/**
|
|
971
|
+
* Aliases visible to the caller (their project's and the global ones). Super admins
|
|
972
|
+
* can pass `projectId` to see another project's view.
|
|
973
|
+
*/
|
|
974
|
+
list(projectId?: string | null, keyword?: string | null, page?: number, size?: number): Promise<Paginated<ModelAlias>>;
|
|
975
|
+
get(id: string): Promise<ModelAlias>;
|
|
976
|
+
/** Create an alias. Non-super-admins always create in their own project. */
|
|
977
|
+
create(alias: ModelAliasInput): Promise<ModelAlias>;
|
|
978
|
+
/** Change target, fallbacks, defaults and description. `name` and the scope are immutable. */
|
|
979
|
+
update(id: string, alias: ModelAliasInput): Promise<ModelAlias>;
|
|
980
|
+
/**
|
|
981
|
+
* Delete an alias. Refused with a 409 while agents still reference it: use
|
|
982
|
+
* {@link ModelAliasesApi.inUse} on the error to read which ones.
|
|
983
|
+
*/
|
|
984
|
+
remove(id: string): Promise<void>;
|
|
985
|
+
/** Agents that reference the alias, and in which model slot. */
|
|
986
|
+
impact(id: string): Promise<AliasImpact>;
|
|
987
|
+
/**
|
|
988
|
+
* Run the health check now (registry, announced retirements, credentials). Stores the
|
|
989
|
+
* result in `health` and updates the notifications; it never changes the alias.
|
|
990
|
+
*/
|
|
991
|
+
check(id: string): Promise<ModelAlias>;
|
|
992
|
+
/**
|
|
993
|
+
* Replacement and fallback candidates for the alias' target, or for `model` (e.g. a
|
|
994
|
+
* fallback that went missing). A proposal only: nothing is applied.
|
|
995
|
+
*/
|
|
996
|
+
suggestions(id: string, model?: string | null, limit?: number): Promise<AliasSuggestions>;
|
|
997
|
+
/**
|
|
998
|
+
* The agents blocking a delete, when `error` is the 409 of {@link ModelAliasesApi.remove};
|
|
999
|
+
* `null` for any other error.
|
|
1000
|
+
*/
|
|
1001
|
+
static inUse(error: unknown): AliasImpact | null;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
export declare interface ModelAliasHealth {
|
|
1005
|
+
status: ModelAliasHealthStatus;
|
|
1006
|
+
checkedAt?: string | null;
|
|
1007
|
+
issues: ModelAliasIssue[];
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
export declare type ModelAliasHealthStatus = 'unknown' | 'ok' | 'deprecating' | 'missing' | 'no_credentials';
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* What to send to create or update an alias. The server-managed fields (`health`,
|
|
1014
|
+
* `history`, timestamps) are not part of it; `name` is required but immutable, and
|
|
1015
|
+
* the scope can only be chosen (via `projectId`) by super admins when creating.
|
|
1016
|
+
*/
|
|
1017
|
+
export declare interface ModelAliasInput {
|
|
1018
|
+
name: string;
|
|
1019
|
+
target: string;
|
|
1020
|
+
projectId?: string | null;
|
|
1021
|
+
description?: string | null;
|
|
1022
|
+
fallbacks?: string[];
|
|
1023
|
+
defaults?: ModelAliasDefaults;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
/** A problem found by the health check on one of the alias' models. */
|
|
1027
|
+
export declare interface ModelAliasIssue {
|
|
1028
|
+
model: string;
|
|
1029
|
+
role: ModelAliasIssueRole;
|
|
1030
|
+
status: ModelAliasHealthStatus;
|
|
1031
|
+
detail?: string | null;
|
|
1032
|
+
/** Provider-announced retirement date (`YYYY-MM-DD`), when known. */
|
|
1033
|
+
deprecationDate?: string | null;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
export declare type ModelAliasIssueRole = 'target' | 'fallback';
|
|
1037
|
+
|
|
1038
|
+
export declare type ModelCapability = 'function_calling' | 'vision' | 'audio_input' | 'pdf_input' | 'reasoning';
|
|
1039
|
+
|
|
822
1040
|
export declare interface ModelConfiguration {
|
|
823
|
-
/**
|
|
1041
|
+
/**
|
|
1042
|
+
* litellm-style "<provider>/<model>" string (e.g. "fireworks/accounts/fireworks/models/minimax-m3"), or a
|
|
1043
|
+
* model alias reference "alias:<name>" (see `aliasRef`), resolved by the server. Use the known-models API
|
|
1044
|
+
* for the current list.
|
|
1045
|
+
*/
|
|
824
1046
|
modelName?: string;
|
|
825
1047
|
temperature?: number;
|
|
826
1048
|
reasoningEffort?: ReasoningEffort;
|
|
@@ -846,8 +1068,26 @@ export declare interface ModelConfiguration {
|
|
|
846
1068
|
openrouterModelName?: string;
|
|
847
1069
|
}
|
|
848
1070
|
|
|
1071
|
+
/** What litellm's registry knows about a model. */
|
|
1072
|
+
export declare interface ModelProfile {
|
|
1073
|
+
model: string;
|
|
1074
|
+
contextWindow?: number | null;
|
|
1075
|
+
/** USD per million tokens. */
|
|
1076
|
+
inputCostPerMillion?: number | null;
|
|
1077
|
+
outputCostPerMillion?: number | null;
|
|
1078
|
+
capabilities: ModelCapability[];
|
|
1079
|
+
}
|
|
1080
|
+
|
|
849
1081
|
export declare type ModelProvider = 'google' | 'openai' | 'grok' | 'fireworks' | 'together' | 'ollama' | 'openai_compatible' | 'openrouter';
|
|
850
1082
|
|
|
1083
|
+
/** A candidate to replace a model, or to add as a fallback. */
|
|
1084
|
+
export declare interface ModelSuggestion extends ModelProfile {
|
|
1085
|
+
provider: string;
|
|
1086
|
+
sameProvider: boolean;
|
|
1087
|
+
/** e.g. a smaller context window, a much higher price. */
|
|
1088
|
+
warnings: string[];
|
|
1089
|
+
}
|
|
1090
|
+
|
|
851
1091
|
export declare interface NetworkConfiguration {
|
|
852
1092
|
allowedWebsites?: string[];
|
|
853
1093
|
allowedIps?: string[];
|
|
@@ -877,6 +1117,79 @@ export declare interface NodeExecutionResult {
|
|
|
877
1117
|
|
|
878
1118
|
export declare type NodeType = 'start' | 'action' | 'condition' | 'loop' | 'tool' | 'agent' | 'set_var' | 'output' | 'workflow' | 'resource' | 'script';
|
|
879
1119
|
|
|
1120
|
+
/**
|
|
1121
|
+
* An in-platform notification (badge + banner). `title` and `message` are an English
|
|
1122
|
+
* fallback: clients localize from `code` and `data`.
|
|
1123
|
+
*/
|
|
1124
|
+
declare interface Notification_2 {
|
|
1125
|
+
id: string;
|
|
1126
|
+
/** null => platform-wide, visible to super admins only. */
|
|
1127
|
+
projectId?: string | null;
|
|
1128
|
+
/** Producer area, e.g. `model_alias`. */
|
|
1129
|
+
type: string;
|
|
1130
|
+
/** Stable machine code, e.g. `model_alias.missing`, `model_alias.runtime_fallback`. */
|
|
1131
|
+
code: string;
|
|
1132
|
+
severity: NotificationSeverity;
|
|
1133
|
+
title: string;
|
|
1134
|
+
message: string;
|
|
1135
|
+
/** What it is about, for deep links. */
|
|
1136
|
+
entityType?: string | null;
|
|
1137
|
+
entityId?: string | null;
|
|
1138
|
+
dedupeKey?: string | null;
|
|
1139
|
+
data: Record<string, unknown>;
|
|
1140
|
+
createdAt?: string;
|
|
1141
|
+
readAt?: string | null;
|
|
1142
|
+
readBy?: string | null;
|
|
1143
|
+
/** Set when the problem it describes no longer applies. */
|
|
1144
|
+
resolvedAt?: string | null;
|
|
1145
|
+
}
|
|
1146
|
+
export { Notification_2 as Notification }
|
|
1147
|
+
|
|
1148
|
+
/** A place where a project's human tasks are announced (e.g. a Telegram group). */
|
|
1149
|
+
export declare interface NotificationChannel {
|
|
1150
|
+
id: string;
|
|
1151
|
+
projectId: string;
|
|
1152
|
+
provider: string;
|
|
1153
|
+
chatId: string;
|
|
1154
|
+
title?: string;
|
|
1155
|
+
status: ChannelStatus;
|
|
1156
|
+
/** Why the channel is not active (e.g. `removed`, `cannot_post`). */
|
|
1157
|
+
statusDetail?: string;
|
|
1158
|
+
includePayload: boolean;
|
|
1159
|
+
locale: string;
|
|
1160
|
+
linkedBy?: string;
|
|
1161
|
+
createdAt?: string;
|
|
1162
|
+
updatedAt?: string;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
export declare interface NotificationListParams {
|
|
1166
|
+
/** Only the ones not read yet. */
|
|
1167
|
+
unreadOnly?: boolean;
|
|
1168
|
+
/** Include the ones whose problem is gone (hidden by default). */
|
|
1169
|
+
includeResolved?: boolean;
|
|
1170
|
+
/** Super admins: the view of this project (plus platform-wide ones). */
|
|
1171
|
+
projectId?: string | null;
|
|
1172
|
+
page?: number;
|
|
1173
|
+
size?: number;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
/**
|
|
1177
|
+
* In-platform notifications. A project sees its own; platform-wide ones (no project)
|
|
1178
|
+
* are for super admins. Agent API keys have no access. Read state is shared by
|
|
1179
|
+
* everyone who can see a notification.
|
|
1180
|
+
*/
|
|
1181
|
+
export declare class NotificationsApi extends HttpApi {
|
|
1182
|
+
constructor(baseUrl: string, auth: string | AuthenticationProvider);
|
|
1183
|
+
list(params?: NotificationListParams): Promise<Paginated<Notification_2>>;
|
|
1184
|
+
/** Open, unread notifications: the value of the badge. */
|
|
1185
|
+
unreadCount(projectId?: string | null): Promise<number>;
|
|
1186
|
+
markRead(id: string): Promise<Notification_2>;
|
|
1187
|
+
/** Mark as read everything the caller can see. */
|
|
1188
|
+
markAllRead(projectId?: string | null): Promise<void>;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
export declare type NotificationSeverity = 'info' | 'warning' | 'critical';
|
|
1192
|
+
|
|
880
1193
|
export declare interface OAuth2CallbackResponse {
|
|
881
1194
|
id?: string;
|
|
882
1195
|
successUrl?: string;
|
|
@@ -964,6 +1277,10 @@ export declare class PersonaSdk {
|
|
|
964
1277
|
missions(authProvider: AuthenticationProvider): MissionsApi;
|
|
965
1278
|
billing(apiKey: string): BillingClient;
|
|
966
1279
|
billing(authProvider: AuthenticationProvider): BillingClient;
|
|
1280
|
+
modelAliases(apiKey: string): ModelAliasesApi;
|
|
1281
|
+
modelAliases(authProvider: AuthenticationProvider): ModelAliasesApi;
|
|
1282
|
+
notifications(apiKey: string): NotificationsApi;
|
|
1283
|
+
notifications(authProvider: AuthenticationProvider): NotificationsApi;
|
|
967
1284
|
values(apiKey: string): ValuesApi;
|
|
968
1285
|
values(authProvider: AuthenticationProvider): ValuesApi;
|
|
969
1286
|
}
|
|
@@ -1076,7 +1393,7 @@ export declare class ProvidersApi extends HttpApi {
|
|
|
1076
1393
|
models(provider: string): Promise<ProviderModel[]>;
|
|
1077
1394
|
}
|
|
1078
1395
|
|
|
1079
|
-
export declare type ReasoningEffort = 'minimal' | 'low' | 'medium' | 'high';
|
|
1396
|
+
export declare type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
1080
1397
|
|
|
1081
1398
|
export declare interface Ref {
|
|
1082
1399
|
nodeId?: string;
|
|
@@ -1496,6 +1813,18 @@ export declare interface UpgradeSubscriptionRequest {
|
|
|
1496
1813
|
toPlanType: string;
|
|
1497
1814
|
}
|
|
1498
1815
|
|
|
1816
|
+
/**
|
|
1817
|
+
* Usage that went through a model alias. The cost is the sum over every concrete model
|
|
1818
|
+
* the alias served, so it follows the alias even when its target changes.
|
|
1819
|
+
*/
|
|
1820
|
+
export declare interface UsageAliasEntry {
|
|
1821
|
+
alias: string;
|
|
1822
|
+
credits: number;
|
|
1823
|
+
count: number;
|
|
1824
|
+
totalCost?: number;
|
|
1825
|
+
totalPrice?: number;
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1499
1828
|
export declare interface UsageCost {
|
|
1500
1829
|
service?: string;
|
|
1501
1830
|
value?: number;
|
|
@@ -1503,6 +1832,8 @@ export declare interface UsageCost {
|
|
|
1503
1832
|
price?: number;
|
|
1504
1833
|
credits?: number;
|
|
1505
1834
|
unit?: string;
|
|
1835
|
+
/** Name of the model alias the usage went through, if any. `service` names the concrete model that served it. */
|
|
1836
|
+
alias?: string | null;
|
|
1506
1837
|
}
|
|
1507
1838
|
|
|
1508
1839
|
export declare interface UsageDailyEntry {
|
|
@@ -1520,6 +1851,8 @@ export declare interface UsageDetail {
|
|
|
1520
1851
|
price?: number;
|
|
1521
1852
|
credits?: number;
|
|
1522
1853
|
unit?: string;
|
|
1854
|
+
/** Name of the model alias the usage went through, if any. `service` names the concrete model that served it. */
|
|
1855
|
+
alias?: string | null;
|
|
1523
1856
|
[key: string]: unknown;
|
|
1524
1857
|
}
|
|
1525
1858
|
|
|
@@ -1544,6 +1877,8 @@ export declare interface UsageStats {
|
|
|
1544
1877
|
totals: UsageTotals;
|
|
1545
1878
|
daily: UsageDailyEntry[];
|
|
1546
1879
|
byModel: UsageModelEntry[];
|
|
1880
|
+
/** Breakdown by model alias; empty (or absent on an older billing service) when none was used. */
|
|
1881
|
+
byAlias?: UsageAliasEntry[];
|
|
1547
1882
|
availableModels: string[];
|
|
1548
1883
|
hasCostData?: boolean;
|
|
1549
1884
|
costDataMode?: 'actual' | 'estimated_price' | 'mixed' | 'none';
|
|
@@ -1682,6 +2017,7 @@ export declare class WorkflowsApi extends HttpApi {
|
|
|
1682
2017
|
get(workflowId: string): Promise<Workflow>;
|
|
1683
2018
|
executions(): WorkflowExecutionsApi;
|
|
1684
2019
|
humanTasks(): HumanTasksApi;
|
|
2020
|
+
channels(): ChannelsApi;
|
|
1685
2021
|
listRevisions(workflowId: string): Promise<RevisionType[]>;
|
|
1686
2022
|
getRevision(workflowId: string, revisionId: string): Promise<RevisionType>;
|
|
1687
2023
|
rollback(workflowId: string, revisionId: string): Promise<Workflow>;
|
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.
|
|
5
|
+
"version": "0.1.115",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "vite",
|
package/src/agents/types.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
}
|
package/src/billing/types.ts
CHANGED
|
@@ -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';
|
package/src/index.ts
CHANGED
|
@@ -101,6 +101,7 @@ export type {
|
|
|
101
101
|
export { WorkflowsApi } from './workflows/workflows-api';
|
|
102
102
|
export { WorkflowExecutionsApi } from './workflows/workflow-executions-api';
|
|
103
103
|
export { HumanTasksApi } from './workflows/human-tasks-api';
|
|
104
|
+
export { ChannelsApi } from './workflows/channels-api';
|
|
104
105
|
export type {
|
|
105
106
|
Workflow,
|
|
106
107
|
Node,
|
|
@@ -121,6 +122,11 @@ export type {
|
|
|
121
122
|
WorkflowResult,
|
|
122
123
|
ExecuteRequest,
|
|
123
124
|
HumanTask,
|
|
125
|
+
NotificationChannel,
|
|
126
|
+
ChannelIdentity,
|
|
127
|
+
ChannelProvider,
|
|
128
|
+
ChannelLink,
|
|
129
|
+
ChannelStatus,
|
|
124
130
|
AgentValue,
|
|
125
131
|
ContentItem,
|
|
126
132
|
ContentItemFile,
|
|
@@ -174,6 +180,26 @@ export { MarkupRulesApi } from './markup-rules/markup-rules-api';
|
|
|
174
180
|
export type { MarkupRule } from './markup-rules/types';
|
|
175
181
|
export { ProvidersApi } from './providers/providers-api';
|
|
176
182
|
export type { Provider, ProviderModel } from './providers/types';
|
|
183
|
+
export { ModelAliasesApi } from './model-aliases/model-aliases-api';
|
|
184
|
+
export { ALIAS_PREFIX, isAliasRef, aliasNameFromRef, aliasRef } from './model-aliases/references';
|
|
185
|
+
export type {
|
|
186
|
+
ModelAlias,
|
|
187
|
+
ModelAliasInput,
|
|
188
|
+
ModelAliasDefaults,
|
|
189
|
+
ModelAliasHealth,
|
|
190
|
+
ModelAliasHealthStatus,
|
|
191
|
+
ModelAliasIssue,
|
|
192
|
+
ModelAliasIssueRole,
|
|
193
|
+
ModelAliasChange,
|
|
194
|
+
AliasImpact,
|
|
195
|
+
AliasUsage,
|
|
196
|
+
AliasSuggestions,
|
|
197
|
+
ModelSuggestion,
|
|
198
|
+
ModelProfile,
|
|
199
|
+
ModelCapability,
|
|
200
|
+
} from './model-aliases/types';
|
|
201
|
+
export { NotificationsApi } from './notifications/notifications-api';
|
|
202
|
+
export type { Notification, NotificationSeverity, NotificationListParams } from './notifications/types';
|
|
177
203
|
export type { Revision as RevisionType } from './revisions/types';
|
|
178
204
|
export { BillingClient } from './billing/billing-client';
|
|
179
205
|
export { ValuesApi } from './values/values-api';
|
|
@@ -194,6 +220,7 @@ export type {
|
|
|
194
220
|
UsageTotals,
|
|
195
221
|
UsageDailyEntry,
|
|
196
222
|
UsageModelEntry,
|
|
223
|
+
UsageAliasEntry,
|
|
197
224
|
UsageDetail,
|
|
198
225
|
UsagePage,
|
|
199
226
|
} from './billing/types';
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { HttpApi } from '../http-api';
|
|
2
|
+
import { Paginated } from '../paginated';
|
|
3
|
+
import { AuthenticationProvider } from '../auth/authentication-provider';
|
|
4
|
+
import { ApiException } from '../exceptions';
|
|
5
|
+
import { AliasImpact, AliasSuggestions, ModelAlias, ModelAliasInput } from './types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Model aliases: named indirections (`alias:<name>`) to a concrete model, with
|
|
9
|
+
* ordered fallbacks. Global aliases are managed by super admins; project aliases by
|
|
10
|
+
* super admins, project admins and the project API key (not plain users, nor agent
|
|
11
|
+
* keys). Everyone in a project can read its aliases and the global ones.
|
|
12
|
+
*/
|
|
13
|
+
export class ModelAliasesApi extends HttpApi {
|
|
14
|
+
constructor(baseUrl: string, auth: string | AuthenticationProvider) {
|
|
15
|
+
super(baseUrl, auth);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Aliases visible to the caller (their project's and the global ones). Super admins
|
|
20
|
+
* can pass `projectId` to see another project's view.
|
|
21
|
+
*/
|
|
22
|
+
async list(
|
|
23
|
+
projectId?: string | null,
|
|
24
|
+
keyword?: string | null,
|
|
25
|
+
page?: number,
|
|
26
|
+
size?: number
|
|
27
|
+
): Promise<Paginated<ModelAlias>> {
|
|
28
|
+
const { page: p, size: s } = this.normalizePageParams(page, size);
|
|
29
|
+
const params: Record<string, unknown> = { page: p, size: s };
|
|
30
|
+
if (projectId) params.projectId = projectId;
|
|
31
|
+
if (keyword) params.keyword = keyword;
|
|
32
|
+
return this.httpGet<Paginated<ModelAlias>>('/model-aliases', params);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async get(id: string): Promise<ModelAlias> {
|
|
36
|
+
return this.httpGet<ModelAlias>('/model-aliases/' + id);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Create an alias. Non-super-admins always create in their own project. */
|
|
40
|
+
async create(alias: ModelAliasInput): Promise<ModelAlias> {
|
|
41
|
+
return this.httpPost<ModelAlias>('/model-aliases', alias);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Change target, fallbacks, defaults and description. `name` and the scope are immutable. */
|
|
45
|
+
async update(id: string, alias: ModelAliasInput): Promise<ModelAlias> {
|
|
46
|
+
return this.httpPut<ModelAlias>('/model-aliases/' + id, alias);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Delete an alias. Refused with a 409 while agents still reference it: use
|
|
51
|
+
* {@link ModelAliasesApi.inUse} on the error to read which ones.
|
|
52
|
+
*/
|
|
53
|
+
async remove(id: string): Promise<void> {
|
|
54
|
+
await this.httpDelete('/model-aliases/' + id);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Agents that reference the alias, and in which model slot. */
|
|
58
|
+
async impact(id: string): Promise<AliasImpact> {
|
|
59
|
+
return this.httpGet<AliasImpact>('/model-aliases/' + id + '/impact');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Run the health check now (registry, announced retirements, credentials). Stores the
|
|
64
|
+
* result in `health` and updates the notifications; it never changes the alias.
|
|
65
|
+
*/
|
|
66
|
+
async check(id: string): Promise<ModelAlias> {
|
|
67
|
+
return this.httpPost<ModelAlias>('/model-aliases/' + id + '/check');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Replacement and fallback candidates for the alias' target, or for `model` (e.g. a
|
|
72
|
+
* fallback that went missing). A proposal only: nothing is applied.
|
|
73
|
+
*/
|
|
74
|
+
async suggestions(id: string, model?: string | null, limit?: number): Promise<AliasSuggestions> {
|
|
75
|
+
const params: Record<string, unknown> = {};
|
|
76
|
+
if (model) params.model = model;
|
|
77
|
+
if (limit !== undefined) params.limit = limit;
|
|
78
|
+
return this.httpGet<AliasSuggestions>('/model-aliases/' + id + '/suggestions', params);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The agents blocking a delete, when `error` is the 409 of {@link ModelAliasesApi.remove};
|
|
83
|
+
* `null` for any other error.
|
|
84
|
+
*/
|
|
85
|
+
static inUse(error: unknown): AliasImpact | null {
|
|
86
|
+
if (!(error instanceof ApiException) || error.statusCode !== 409) return null;
|
|
87
|
+
try {
|
|
88
|
+
const impact = JSON.parse(error.body)?.detail?.impact;
|
|
89
|
+
return impact && typeof impact.total === 'number' ? (impact as AliasImpact) : null;
|
|
90
|
+
} catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|