@umbraco-ai/core 1.0.0 → 1.1.0

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": "@umbraco-ai/core",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "types": "./types/umbraco-ai-public-types.d.ts",
6
6
  "files": [
@@ -4,7 +4,8 @@ import type { ManifestBase } from '@umbraco-cms/backoffice/extension-api';
4
4
  import { Observable } from '@umbraco-cms/backoffice/external/rxjs';
5
5
  import { Observable as Observable_2 } from 'rxjs';
6
6
  import { TemplateResult } from 'lit-html';
7
- import type { TemplateResult as TemplateResult_2 } from '@umbraco-cms/backoffice/external/lit';
7
+ import { TemplateResult as TemplateResult_2 } from '@umbraco-cms/backoffice/external/lit';
8
+ import type { UmbApi } from '@umbraco-cms/backoffice/extension-api';
8
9
  import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
9
10
  import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';
10
11
  import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
@@ -109,6 +110,33 @@ declare type PropertyChangeModel = {
109
110
  */
110
111
  export declare function resolveEntityAdapterByType(entityType: string): Promise<UaiEntityAdapterApi | undefined>;
111
112
 
113
+ /**
114
+ * Converts a string to camelCase by splitting on separators (-, _, ., spaces).
115
+ * Used for converting tool/scope IDs to localization key format.
116
+ *
117
+ * @example
118
+ * toCamelCase("content-read") // "contentRead"
119
+ * toCamelCase("media_write") // "mediaWrite"
120
+ * toCamelCase("some.scope") // "someScope"
121
+ */
122
+ export declare function toCamelCase(str: string): string;
123
+
124
+ export declare type ToolItemResponseModel = {
125
+ id: string;
126
+ name: string;
127
+ description: string;
128
+ scopeId: string;
129
+ isDestructive: boolean;
130
+ tags: Array<string>;
131
+ };
132
+
133
+ export declare type ToolScopeItemResponseModel = {
134
+ id: string;
135
+ icon: string;
136
+ isDestructive: boolean;
137
+ domain: string;
138
+ };
139
+
112
140
  /**
113
141
  * A constant representing an empty GUID.
114
142
  * @public
@@ -225,7 +253,7 @@ export declare interface UaiChatResult {
225
253
  * Chat message role.
226
254
  * @public
227
255
  */
228
- export declare type UaiChatRole = 'user' | 'assistant' | 'system';
256
+ export declare type UaiChatRole = "user" | "assistant" | "system";
229
257
 
230
258
  /**
231
259
  * Streaming chunk from chat completion.
@@ -641,10 +669,37 @@ export declare class UaiEntityDeletedRedirectController extends UmbControllerBas
641
669
  constructor(host: UmbControllerHost, args: UaiEntityDeletedRedirectArgs);
642
670
  }
643
671
 
672
+ /**
673
+ * Frontend tool metadata for display in tool pickers.
674
+ * This is the minimal data needed by consumers to list available frontend tools.
675
+ */
676
+ export declare interface UaiFrontendToolData {
677
+ /** Unique tool identifier (matches AG-UI tool call name) */
678
+ id: string;
679
+ /** Display name for the tool */
680
+ name: string;
681
+ /** Description of what the tool does */
682
+ description: string;
683
+ /** Scope identifier for permission grouping */
684
+ scopeId: string;
685
+ }
686
+
687
+ /**
688
+ * Repository API for accessing frontend tool metadata.
689
+ * Implemented by packages that provide frontend tools (e.g., Copilot).
690
+ */
691
+ export declare interface UaiFrontendToolRepositoryApi extends UmbApi {
692
+ /**
693
+ * Get all available frontend tools.
694
+ * @returns Array of frontend tool metadata
695
+ */
696
+ getTools(): Promise<UaiFrontendToolData[]>;
697
+ }
698
+
644
699
  export declare interface UaiItemPickerModalData {
645
700
  items?: UaiPickableItemModel[];
646
701
  fetchItems?: () => Promise<UaiPickableItemModel[]>;
647
- selectionMode?: 'single' | 'multiple';
702
+ selectionMode?: "single" | "multiple";
648
703
  tagTemplate?: (item: UaiPickableItemModel) => TemplateResult_2;
649
704
  title?: string;
650
705
  buttonLabel?: string;
@@ -988,6 +1043,295 @@ export declare class UaiTagsInputElement extends UaiTagsInputElement_base {
988
1043
 
989
1044
  declare const UaiTagsInputElement_base: (new (...args: any[]) => UUIFormControlMixinElement<FormData | FormDataEntryValue>) & typeof UmbLitElement;
990
1045
 
1046
+ /**
1047
+ * Tool with permission state.
1048
+ */
1049
+ export declare interface UaiToolPermission {
1050
+ toolId: string;
1051
+ state: UaiToolPermissionState;
1052
+ }
1053
+
1054
+ /**
1055
+ * Component for managing individual tool permission overrides.
1056
+ * Displays inherited tools with "Deny" buttons and allows adding new tools with "Allow" permission.
1057
+ *
1058
+ * @fires change - Fires when permissions change
1059
+ *
1060
+ * @public
1061
+ */
1062
+ export declare class UaiToolPermissionsOverrideElement extends UmbLitElement {
1063
+ #private;
1064
+ /**
1065
+ * Map of tool ID to full tool data.
1066
+ */
1067
+ private _toolDataMap;
1068
+ /**
1069
+ * Inherited tool IDs from agent defaults.
1070
+ */
1071
+ inheritedToolIds: string[];
1072
+ /**
1073
+ * Tool IDs that are explicitly allowed (additive).
1074
+ */
1075
+ allowedToolIds: string[];
1076
+ /**
1077
+ * Tool IDs that are explicitly denied (subtractive).
1078
+ */
1079
+ deniedToolIds: string[];
1080
+ /**
1081
+ * Whether the component is in readonly mode.
1082
+ */
1083
+ readonly: boolean;
1084
+ connectedCallback(): void;
1085
+ updated(changedProperties: Map<string, unknown>): void;
1086
+ /**
1087
+ * Load full tool data for all tools.
1088
+ */
1089
+ private _loadToolData;
1090
+ /**
1091
+ * Computed list of all tools with their permission states.
1092
+ */
1093
+ private get _allTools();
1094
+ /**
1095
+ * Add a new allowed tool.
1096
+ */
1097
+ private _addAllowedTool;
1098
+ /**
1099
+ * Fetch available tools for the picker modal.
1100
+ */
1101
+ private _fetchAvailableTools;
1102
+ /**
1103
+ * Deny a tool (move to denied list).
1104
+ */
1105
+ private _denyTool;
1106
+ /**
1107
+ * Remove a tool from denied list (allow it again).
1108
+ */
1109
+ private _allowTool;
1110
+ /**
1111
+ * Remove an explicitly allowed tool.
1112
+ */
1113
+ private _removeAllowedTool;
1114
+ /**
1115
+ * Dispatch change event.
1116
+ */
1117
+ private _dispatchChangeEvent;
1118
+ /**
1119
+ * Render a tool permission item.
1120
+ */
1121
+ private _renderToolItem;
1122
+ render(): TemplateResult<1>;
1123
+ static styles: CSSResult[];
1124
+ }
1125
+
1126
+ /**
1127
+ * Permission state for a tool override.
1128
+ */
1129
+ export declare type UaiToolPermissionState = "inherited" | "allowed" | "denied";
1130
+
1131
+ /**
1132
+ * Tool picker component that allows selecting one or more AI tools.
1133
+ *
1134
+ * @fires change - Fires when the selection changes (UmbChangeEvent).
1135
+ *
1136
+ * @example
1137
+ * Multiple selection (default):
1138
+ * ```html
1139
+ * <uai-tool-picker
1140
+ * .value=${["tool-id-1", "tool-id-2"]}
1141
+ * @change=${(e) => console.log(e.target.value)}
1142
+ * ></uai-tool-picker>
1143
+ * ```
1144
+ * @public
1145
+ */
1146
+ export declare class UaiToolPickerElement extends UaiToolPickerElement_base {
1147
+ #private;
1148
+ /**
1149
+ * Readonly mode - cannot add or remove.
1150
+ */
1151
+ readonly: boolean;
1152
+ /**
1153
+ * Optional frontend tools to include alongside server-fetched tools.
1154
+ * These tools will be combined with the backend tools when displaying the picker.
1155
+ */
1156
+ frontendTools?: UaiFrontendToolData[];
1157
+ /**
1158
+ * The selected tool ID(s).
1159
+ */
1160
+ set value(val: string[] | undefined);
1161
+ get value(): string[] | undefined;
1162
+ private _selection;
1163
+ private _items;
1164
+ private _loading;
1165
+ updated(changedProperties: Map<PropertyKey, unknown>): void;
1166
+ render(): TemplateResult<1>;
1167
+ static styles: CSSResult[];
1168
+ }
1169
+
1170
+ declare const UaiToolPickerElement_base: HTMLElementConstructor<UmbFormControlMixinElement<string[] | undefined>> & typeof UmbLitElement;
1171
+
1172
+ /**
1173
+ * Repository for tool operations.
1174
+ */
1175
+ export declare class UaiToolRepository extends UmbControllerBase {
1176
+ #private;
1177
+ constructor(host: UmbControllerHost);
1178
+ /**
1179
+ * Gets all registered tool scopes.
1180
+ */
1181
+ getToolScopes(): Promise<{
1182
+ data?: Array<ToolScopeItemResponseModel>;
1183
+ error?: unknown;
1184
+ }>;
1185
+ /**
1186
+ * Gets all registered tools.
1187
+ */
1188
+ getTools(): Promise<{
1189
+ data?: Array<ToolItemResponseModel>;
1190
+ error?: unknown;
1191
+ }>;
1192
+ }
1193
+
1194
+ /**
1195
+ * Tool scope with permission state.
1196
+ */
1197
+ export declare interface UaiToolScopePermission {
1198
+ scopeId: string;
1199
+ state: UaiToolScopePermissionState;
1200
+ }
1201
+
1202
+ export declare class UaiToolScopePermissionsElement extends UaiToolScopePermissionsElement_base {
1203
+ #private;
1204
+ /**
1205
+ * Readonly mode - cannot toggle permissions.
1206
+ */
1207
+ readonly: boolean;
1208
+ /**
1209
+ * The selected tool scope IDs.
1210
+ */
1211
+ set value(val: string[] | undefined);
1212
+ get value(): string[] | undefined;
1213
+ private _selection;
1214
+ private _groups;
1215
+ private _loading;
1216
+ connectedCallback(): void;
1217
+ render(): TemplateResult<1>;
1218
+ static styles: CSSResult[];
1219
+ }
1220
+
1221
+ declare const UaiToolScopePermissionsElement_base: HTMLElementConstructor<UmbFormControlMixinElement<string[] | undefined>> & typeof UmbLitElement;
1222
+
1223
+ /**
1224
+ * Component for managing tool scope permission overrides.
1225
+ * Displays inherited scopes with "Deny" buttons and allows adding new scopes with "Allow" permission.
1226
+ *
1227
+ * @fires change - Fires when permissions change
1228
+ *
1229
+ * @public
1230
+ */
1231
+ export declare class UaiToolScopePermissionsOverrideElement extends UmbLitElement {
1232
+ #private;
1233
+ /**
1234
+ * Map of scope ID to full scope data.
1235
+ */
1236
+ private _scopeDataMap;
1237
+ /**
1238
+ * Inherited scope IDs from agent defaults.
1239
+ */
1240
+ inheritedScopeIds: string[];
1241
+ /**
1242
+ * Scope IDs that are explicitly allowed (additive).
1243
+ */
1244
+ allowedScopeIds: string[];
1245
+ /**
1246
+ * Scope IDs that are explicitly denied (subtractive).
1247
+ */
1248
+ deniedScopeIds: string[];
1249
+ /**
1250
+ * Whether the component is in readonly mode.
1251
+ */
1252
+ readonly: boolean;
1253
+ connectedCallback(): void;
1254
+ updated(changedProperties: Map<string, unknown>): void;
1255
+ /**
1256
+ * Load full scope data for all scopes.
1257
+ */
1258
+ private _loadScopeData;
1259
+ /**
1260
+ * Computed list of all scopes with their permission states.
1261
+ */
1262
+ private get _allScopes();
1263
+ /**
1264
+ * Add a new allowed scope.
1265
+ */
1266
+ private _addAllowedScope;
1267
+ /**
1268
+ * Fetch available tool scopes for the picker modal.
1269
+ */
1270
+ private _fetchAvailableScopes;
1271
+ /**
1272
+ * Deny a scope (move to denied list).
1273
+ */
1274
+ private _denyScope;
1275
+ /**
1276
+ * Remove a scope from denied list (allow it again).
1277
+ */
1278
+ private _allowScope;
1279
+ /**
1280
+ * Remove an explicitly allowed scope.
1281
+ */
1282
+ private _removeAllowedScope;
1283
+ /**
1284
+ * Dispatch change event.
1285
+ */
1286
+ private _dispatchChangeEvent;
1287
+ /**
1288
+ * Render a scope permission item.
1289
+ */
1290
+ private _renderScopeItem;
1291
+ render(): TemplateResult<1>;
1292
+ static styles: CSSResult[];
1293
+ }
1294
+
1295
+ /**
1296
+ * Permission state for a tool scope override.
1297
+ */
1298
+ export declare type UaiToolScopePermissionState = "inherited" | "allowed" | "denied";
1299
+
1300
+ /**
1301
+ * Tool scope picker component that allows selecting one or more tool scopes.
1302
+ *
1303
+ * @fires change - Fires when the selection changes (UmbChangeEvent).
1304
+ *
1305
+ * @example
1306
+ * Multiple selection:
1307
+ * ```html
1308
+ * <uai-tool-scope-picker
1309
+ * .value=${["content-read", "media-write"]}
1310
+ * @change=${(e) => console.log(e.target.value)}
1311
+ * ></uai-tool-scope-picker>
1312
+ * ```
1313
+ * @public
1314
+ */
1315
+ export declare class UaiToolScopePickerElement extends UaiToolScopePickerElement_base {
1316
+ #private;
1317
+ /**
1318
+ * Readonly mode - cannot add or remove.
1319
+ */
1320
+ readonly: boolean;
1321
+ /**
1322
+ * The selected tool scope ID(s).
1323
+ */
1324
+ set value(val: string[] | undefined);
1325
+ get value(): string[] | undefined;
1326
+ private _selection;
1327
+ private _items;
1328
+ private _loading;
1329
+ render(): TemplateResult<1>;
1330
+ static styles: CSSResult[];
1331
+ }
1332
+
1333
+ declare const UaiToolScopePickerElement_base: HTMLElementConstructor<UmbFormControlMixinElement<string[] | undefined>> & typeof UmbLitElement;
1334
+
991
1335
  /**
992
1336
  * Unified repository for version history operations across all entity types.
993
1337
  * Uses the unified versioning API endpoint instead of entity-specific endpoints.
@@ -1023,6 +1367,124 @@ export declare class UaiUnifiedVersionHistoryRepository {
1023
1367
  rollback(entityType: string, entityId: string, version: number): Promise<boolean>;
1024
1368
  }
1025
1369
 
1370
+ /**
1371
+ * Configuration for the user group settings list component.
1372
+ * @template TSettings - The type of settings managed for each user group
1373
+ * @public
1374
+ */
1375
+ export declare interface UaiUserGroupSettingsConfig<TSettings> {
1376
+ /** Modal configuration for editing settings */
1377
+ editorModal: {
1378
+ /** Modal token to open for editing */
1379
+ token: UmbModalToken<any, any>;
1380
+ /** Factory to create modal data */
1381
+ createData: (userGroupId: string, userGroupName: string, existingSettings?: TSettings) => any;
1382
+ /** Extract settings from modal result */
1383
+ extractValue: (modalResult: any) => TSettings;
1384
+ };
1385
+ /** Display configuration */
1386
+ display: {
1387
+ /** Render summary text/content for list item detail */
1388
+ renderSummary: (settings: TSettings) => TemplateResult_2 | string;
1389
+ /** Optional: Render tags/badges in list item */
1390
+ renderTags?: (settings: TSettings) => TemplateResult_2;
1391
+ };
1392
+ /** Localization (all optional with sensible defaults) */
1393
+ labels?: {
1394
+ /** Box headline (default: "User Group Overrides") */
1395
+ headline?: string;
1396
+ /** Add button label (default: "Add User Group Override") */
1397
+ addButton?: string;
1398
+ };
1399
+ }
1400
+
1401
+ /**
1402
+ * Generic reusable component for managing user-group-specific settings for any feature.
1403
+ * Handles list display, add/edit/remove workflows, and user group picker integration.
1404
+ *
1405
+ * @fires change - Fires when the value changes
1406
+ *
1407
+ * @example
1408
+ * ```typescript
1409
+ * const config: UaiUserGroupSettingsConfig<MySettings> = {
1410
+ * editorModal: {
1411
+ * token: MY_EDITOR_MODAL_TOKEN,
1412
+ * createData: (id, name, existing) => ({ userGroupId: id, userGroupName: name, settings: existing }),
1413
+ * extractValue: (result) => result.settings,
1414
+ * },
1415
+ * display: {
1416
+ * renderSummary: (settings) => `${settings.count} items configured`,
1417
+ * renderTags: (settings) => html`<uui-tag>Active</uui-tag>`,
1418
+ * },
1419
+ * labels: {
1420
+ * headline: 'Custom Settings',
1421
+ * addButton: 'Add Custom Setting',
1422
+ * },
1423
+ * };
1424
+ * ```
1425
+ *
1426
+ * @public
1427
+ */
1428
+ export declare class UaiUserGroupSettingsListElement<TSettings> extends UmbLitElement {
1429
+ #private;
1430
+ /**
1431
+ * Map of user group IDs to their settings.
1432
+ * Dictionary key is the user group ID (GUID as string).
1433
+ */
1434
+ value: Record<string, TSettings>;
1435
+ /**
1436
+ * Configuration for the component (modal, display, labels).
1437
+ */
1438
+ config: UaiUserGroupSettingsConfig<TSettings>;
1439
+ /**
1440
+ * Whether the component is in readonly mode.
1441
+ */
1442
+ readonly: boolean;
1443
+ /**
1444
+ * Internal state for resolved user group names.
1445
+ */
1446
+ private _userGroupNames;
1447
+ /**
1448
+ * Computed labels with defaults.
1449
+ */
1450
+ private get _labels();
1451
+ /**
1452
+ * Check if there are any user groups configured.
1453
+ */
1454
+ private get _hasUserGroups();
1455
+ /**
1456
+ * Get user group entries as array for rendering.
1457
+ */
1458
+ private get _userGroupEntries();
1459
+ connectedCallback(): void;
1460
+ /**
1461
+ * Load user group names for all configured user groups.
1462
+ */
1463
+ private _loadUserGroupNames;
1464
+ /**
1465
+ * Get user group name by ID.
1466
+ */
1467
+ private _getUserGroupName;
1468
+ /**
1469
+ * Add a new user group override.
1470
+ */
1471
+ private _addUserGroup;
1472
+ /**
1473
+ * Edit an existing user group override.
1474
+ */
1475
+ private _editUserGroup;
1476
+ /**
1477
+ * Remove a user group override.
1478
+ */
1479
+ private _removeUserGroup;
1480
+ /**
1481
+ * Dispatch change event.
1482
+ */
1483
+ private _dispatchChangeEvent;
1484
+ render(): TemplateResult_2<1>;
1485
+ static styles: CSSResult[];
1486
+ }
1487
+
1026
1488
  /**
1027
1489
  * Response model for version comparison.
1028
1490
  */