Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3.0.5 #14

Merged
merged 30 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5860a5b
feat: interrupted tool call
meta-d Dec 11, 2024
965dfc9
feat: sensitive tools
meta-d Dec 11, 2024
35d4ea0
feat: Interrupted chat
meta-d Dec 12, 2024
c227eba
feat: human in the loop
meta-d Dec 12, 2024
bedd050
feat: reject INTERRUPTED chat
meta-d Dec 12, 2024
b3ee9c0
feat: mutiple tool calls info
meta-d Dec 12, 2024
0e12a68
feat: sensitive operation tool call
meta-d Dec 13, 2024
44f2c35
Merge branch 'develop' into v3.0.4
meta-d Dec 13, 2024
82aaa73
version 3.0.4
meta-d Dec 13, 2024
6a37d8b
feat: primary agent not sensitive
meta-d Dec 13, 2024
d1c7743
feat: conversation summarize
meta-d Dec 14, 2024
7f3e7c7
feat: long term memory
meta-d Dec 15, 2024
4eb5b4b
feat: feeback to summarize long-term memory
meta-d Dec 16, 2024
2bd4bc2
feat: fix agent primary
meta-d Dec 16, 2024
37eef2c
feat: xpert's memory page
meta-d Dec 17, 2024
8d7d0ff
feat: long term memory of xpert
meta-d Dec 17, 2024
2aa1b8a
feat: use long-term memory in chat
meta-d Dec 18, 2024
ff0cc77
feat: add findMyAll in curd service
meta-d Dec 18, 2024
6ab7736
feat: register user
meta-d Dec 18, 2024
b33162c
feat: long-term memory every user
meta-d Dec 18, 2024
2a97e95
feat: long-term memory
meta-d Dec 18, 2024
49b660e
feat: execution tools events
meta-d Dec 18, 2024
73561a6
feat: fix xpert memory
meta-d Dec 18, 2024
3431705
feat: semantic search for long-term store
meta-d Dec 19, 2024
8dd154f
feat: long-term trigger events
meta-d Dec 19, 2024
803fc7a
feat: memory profile
meta-d Dec 20, 2024
7756017
version 3.0.5
meta-d Dec 20, 2024
867226a
feat: update mysql client to 2
meta-d Dec 20, 2024
c90a8ff
feat: memory of xpert
meta-d Dec 20, 2024
6c0cc56
fix: null memory store
meta-d Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: register user
  • Loading branch information
meta-d committed Dec 18, 2024
commit 6ab77366892f856de67903dc0117f770cef41dd0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ElementRef, forwardRef, inject, Input, ViewChild } from '@angular/core'
import { Component, computed, ElementRef, forwardRef, inject, Input, ViewChild } from '@angular/core'
import { ControlValueAccessor, FormGroup, NG_VALUE_ACCESSOR } from '@angular/forms'
import { matchValidator } from '@metad/cloud/auth'
import { AuthService } from '@metad/cloud/state'
Expand All @@ -7,7 +7,8 @@ import { FORMLY_ROW, FORMLY_W_1_2 } from '@metad/story/designer'
import { FormlyFieldConfig } from '@ngx-formly/core'
import { firstValueFrom, map } from 'rxjs'
import { LANGUAGES, RoleService, Store } from '../../../../@core'
import { TranslationBaseComponent } from '../../../language/translation-base.component'
import { TranslationBaseComponent } from '../../../language/'
import { DisplayBehaviour } from '@metad/ocap-core'

@Component({
selector: 'pac-user-basic-info-form',
Expand All @@ -22,6 +23,8 @@ import { TranslationBaseComponent } from '../../../language/translation-base.com
]
})
export class BasicInfoFormComponent extends TranslationBaseComponent implements ControlValueAccessor {
eDisplayBehaviour = DisplayBehaviour

readonly #store = inject(Store)
readonly #roleService = inject(RoleService)
readonly #authService = inject(AuthService)
Expand Down Expand Up @@ -53,6 +56,10 @@ export class BasicInfoFormComponent extends TranslationBaseComponent implements
model = {} as any
fields: FormlyFieldConfig[] = []

get invalid() {
return this.form.invalid
}

onChange: (value: any) => any

writeValue(obj: any): void {
Expand Down Expand Up @@ -157,6 +164,7 @@ export class BasicInfoFormComponent extends TranslationBaseComponent implements
options: this.roles$,
appearance: 'fill',
valueKey: 'key',
displayBehaviour: DisplayBehaviour.descriptionOnly
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<header mat-dialog-title cdkDrag cdkDragRootElement=".cdk-overlay-pane" cdkDragHandle>
<h4 style="pointer-events: none;">
{{ 'PAC.USERS_PAGE.ADD_USER' | translate }}
</h4>
<header cdkDrag cdkDragRootElement=".cdk-overlay-pane" cdkDragHandle class="p-4 cursor-move">
<h4 class="text-xl">
{{ 'PAC.USERS_PAGE.ADD_USER' | translate }}
</h4>
</header>

<mat-dialog-content>
<pac-user-basic-info-form [password]="true"
[isAdmin]="isAdmin"
[isSuperAdmin]="isSuperAdmin"
#userBasicInfo
></pac-user-basic-info-form>
</mat-dialog-content>
<div class="flex flex-col w-full p-4">
<pac-user-basic-info-form [password]="true"
[isAdmin]="isAdmin"
[isSuperAdmin]="isSuperAdmin"
#userBasicInfo
/>
</div>

<mat-dialog-actions align="end">
<div ngmButtonGroup>
<button mat-button mat-dialog-close>
{{ 'COMPONENTS.COMMON.CANCEL' | translate: {Default: 'Cancel'} }}
</button>
<button mat-raised-button color="accent" cdkFocusInitial
[disabled]="userBasicInfo.form.invalid"
(click)="add()">
{{ 'COMPONENTS.COMMON.APPLY' | translate: {Default: 'Apply'} }}
</button>
</div>
</mat-dialog-actions>
<div class="w-full flex justify-end p-2">
<div ngmButtonGroup>
<button mat-button cdkFocusInitial (click)="cancel()">
{{ 'COMPONENTS.COMMON.CANCEL' | translate: {Default: 'Cancel'} }}
</button>
<button mat-raised-button color="accent"
[disabled]="userBasicInfo.invalid"
(click)="add()">
{{ 'COMPONENTS.COMMON.APPLY' | translate: {Default: 'Apply'} }}
</button>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
:host {
width: 600px;
min-width: 600px;
max-width: 100%;
@apply rounded-2xl bg-components-card-bg;
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
import { Component, HostBinding, Inject, Input, OnInit, ViewChild } from '@angular/core'
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'
import { ITag, IUser } from '@metad/contracts'
import { DIALOG_DATA, DialogRef } from '@angular/cdk/dialog'
import { DragDropModule } from '@angular/cdk/drag-drop'
import { ChangeDetectionStrategy, Component, HostBinding, inject, Inject, Input, OnInit, ViewChild } from '@angular/core'
import { FormsModule } from '@angular/forms'
import { MatButtonModule } from '@angular/material/button'
import { MatDialogModule } from '@angular/material/dialog'
import { MatIconModule } from '@angular/material/icon'
import { ITag, IUser } from '@metad/contracts'
import { ButtonGroupDirective } from '@metad/ocap-angular/core'
import { TranslateModule } from '@ngx-translate/core'
import { ToastrService } from '../../../@core'
import { Store } from '../../../@core/services/store.service'
import { BasicInfoFormComponent, UserFormsModule } from '../forms'
import { ButtonGroupDirective } from '@metad/ocap-angular/core'
import { ToastrService } from '../../../@core'

@Component({
standalone: true,
imports: [
FormsModule,
MatDialogModule,
MatIconModule,
MatButtonModule,
DragDropModule,
TranslateModule,
FormsModule,
MatIconModule,
MatButtonModule,
DragDropModule,
TranslateModule,
ButtonGroupDirective,
UserFormsModule
],

UserFormsModule
],
selector: 'pac-user-mutation',
templateUrl: './user-mutation.component.html',
styleUrls: ['./user-mutation.component.scss']
styleUrls: ['./user-mutation.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class UserMutationComponent implements OnInit {
@HostBinding('class.ngm-dialog-container') isDialogContainer = true

readonly dialogRef = inject(DialogRef<{ user: IUser }, UserMutationComponent>)

@ViewChild('userBasicInfo')
userBasicInfo: BasicInfoFormComponent
tags: ITag[]
Expand All @@ -41,17 +42,17 @@ export class UserMutationComponent implements OnInit {
@Input() public isSuperAdmin: boolean

constructor(
protected dialogRef: MatDialogRef<UserMutationComponent>,
protected store: Store,
@Inject(MAT_DIALOG_DATA)
private data: {isAdmin: boolean, isSuperAdmin: boolean},
@Inject(DIALOG_DATA)
private data: { isAdmin: boolean; isSuperAdmin: boolean },
private toastrService: ToastrService
) {}

ngOnInit(): void {
this.isAdmin = this.data.isAdmin
this.isSuperAdmin = this.data.isSuperAdmin
}

selectedTagsEvent(ev) {
this.tags = ev
}
Expand All @@ -60,16 +61,17 @@ export class UserMutationComponent implements OnInit {
this.dialogRef.close({ user })
}

cancel() {
this.dialogRef.close()
}

async add() {
try {
const organization = this.store.selectedOrganization
const user = await this.userBasicInfo.registerUser(
organization?.id,
this.store.userId
)
const user = await this.userBasicInfo.registerUser(organization?.id, this.store.userId)
this.closeDialog(user)
} catch (error) {
this.toastrService.danger(error);
this.toastrService.danger(error)
}
}
}
11 changes: 5 additions & 6 deletions apps/cloud/src/app/features/setting/users/users.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component, ViewChild, effect, inject, signal } from '@angular/core'
import { MatDialog } from '@angular/material/dialog'
import { Dialog } from '@angular/cdk/dialog'
import { ChangeDetectionStrategy, Component, effect, inject, signal } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { Store } from '@metad/cloud/state'
import { Subject, firstValueFrom, map } from 'rxjs'
Expand All @@ -11,7 +11,6 @@ import { userLabel } from '../../../@shared/pipes'
import { SharedModule } from '../../../@shared/shared.module'
import { UserMutationComponent } from '../../../@shared/user'


@Component({
standalone: true,
selector: 'pac-users',
Expand All @@ -28,7 +27,7 @@ export class PACUsersComponent<T extends IUser = IUser> extends TranslationBaseC
private readonly store = inject(Store)
private router = inject(Router)
private _route = inject(ActivatedRoute)
private _dialog = inject(MatDialog)
private _dialog = inject(Dialog)

openedLinks = signal<T[]>([])
currentLink = signal<T | null>(null)
Expand Down Expand Up @@ -89,7 +88,7 @@ export class PACUsersComponent<T extends IUser = IUser> extends TranslationBaseC
}

async invite() {
const result = await firstValueFrom(this._dialog.open(InviteMutationComponent).afterClosed())
const result = await firstValueFrom(this._dialog.open<{total: number}>(InviteMutationComponent).closed)

// 成功邀请人数
if (result?.total) {
Expand All @@ -100,7 +99,7 @@ export class PACUsersComponent<T extends IUser = IUser> extends TranslationBaseC

async addUser() {
const result = await firstValueFrom(
this._dialog.open(UserMutationComponent, { data: { isAdmin: true } }).afterClosed()
this._dialog.open<{user: IUser;}>(UserMutationComponent, { data: { isAdmin: true } }).closed
)
if (result?.user) {
this.router.navigate(['.', result.user.id], { relativeTo: this._route })
Expand Down
1 change: 1 addition & 0 deletions libs/formly/select/select.type.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[searchable]="props?.searchable"
[virtualScroll]="props?.virtualScroll"
[panelWidth]="props?.panelWidth"
[displayBehaviour]="props?.displayBehaviour"
[formControl]="valueFormControl"
[selectOptions]="selectOptions()"

Expand Down
3 changes: 0 additions & 3 deletions packages/angular/common/select/select/select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import {
ContentChild,
ElementRef,
HostBinding,
Renderer2,
TemplateRef,
booleanAttribute,
computed,
effect,
forwardRef,
inject,
input,
signal,
viewChild
Expand Down Expand Up @@ -72,7 +70,6 @@ import { NgmOptionContent } from '../../input/option-content'

OcapCoreModule,
NgmDisplayBehaviourComponent,
NgmOptionContent
]
})
export class NgmSelectComponent implements ControlValueAccessor
Expand Down
6 changes: 5 additions & 1 deletion packages/server/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,13 @@ export class AuthService extends SocialAuthService {

/**
* Shared method involved in
* 1. Create user
* 1. Sign up
* 2. Addition of new user to organization
* 3. User invite accept scenario
*
* @param input
* @param languageCode
* @returns
*/
async register(
input: IUserRegistrationInput,
Expand Down
32 changes: 19 additions & 13 deletions packages/server/src/auth/commands/handlers/auth.register.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,38 @@ import { UserService } from '../../../user/user.service';
import { UnauthorizedException, BadRequestException } from '@nestjs/common';

@CommandHandler(AuthRegisterCommand)
export class AuthRegisterHandler
implements ICommandHandler<AuthRegisterCommand> {
constructor(
private readonly authService: AuthService,
private readonly userService: UserService
) {}
export class AuthRegisterHandler implements ICommandHandler<AuthRegisterCommand> {
constructor(private readonly authService: AuthService, private readonly userService: UserService) {}

/**
* Executes the user registration command, handling specific checks for SUPER_ADMIN role.
*
* @param command The AuthRegisterCommand containing user registration input and optional parameters.
* @returns A Promise resolving to the registered IUser object.
* @throws BadRequestException if input is missing required fields.
* @throws UnauthorizedException if the user initiating registration is not authorized.
*/
public async execute(command: AuthRegisterCommand): Promise<IUser> {
const { input, languageCode } = command;
if (
input.user &&
input.user.role &&
input.user.role.name === RolesEnum.SUPER_ADMIN
) {

// Check if the user role is SUPER_ADMIN and require 'createdById' for verification
if (input.user && input.user.role && input.user.role.name === RolesEnum.SUPER_ADMIN) {
if (!input.createdById) {
throw new BadRequestException()
throw new BadRequestException('Missing createdById for SUPER_ADMIN registration.');
};

// Fetch role details of the creator
const { role } = await this.userService.findOne(input.createdById, {
relations: ['role']
});

// Verify if the creator's role is SUPER_ADMIN
if (role.name !== RolesEnum.SUPER_ADMIN) {
throw new UnauthorizedException();
throw new UnauthorizedException('Only SUPER_ADMIN can register other SUPER_ADMIN users.');
}
}

// Register the user using the AuthService
return await this.authService.register(input, languageCode);
}
}