Skip to content

The open alternative to Salesforce, designed for AI.

Add conversation assistant participation field (#28933)

Raphaël Bosi6096a658f5b2
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-53/2-53-upgrade-version-command.module.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-53/2-53-upgrade-version-command.module.ts
new file mode 100644
index 00000000000..e3b91439b17
--- /dev/null
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-53/2-53-upgrade-version-command.module.ts
@@ -0,0 +1,18 @@
+import { Module } from '@nestjs/common';
+
+import { WorkspaceIteratorModule } from 'src/database/commands/command-runners/workspace-iterator.module';
+import { AddChatAssistantParticipationCommand } from 'src/database/commands/upgrade-version-command/2-53/2-53-workspace-command-1793111719062-add-chat-assistant-participation.command';
+import { ApplicationModule } from 'src/engine/core-modules/application/application.module';
+import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cache.module';
+import { WorkspaceMigrationModule } from 'src/engine/workspace-manager/workspace-migration/workspace-migration.module';
+
+@Module({
+ imports: [
+ ApplicationModule,
+ WorkspaceCacheModule,
+ WorkspaceIteratorModule,
+ WorkspaceMigrationModule,
+ ],
+ providers: [AddChatAssistantParticipationCommand],
+})
+export class V2_53_UpgradeVersionCommandModule {}
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-53/2-53-workspace-command-1793111719062-add-chat-assistant-participation.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-53/2-53-workspace-command-1793111719062-add-chat-assistant-participation.command.ts
new file mode 100644
index 00000000000..e3018385478
--- /dev/null
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-53/2-53-workspace-command-1793111719062-add-chat-assistant-participation.command.ts
@@ -0,0 +1,161 @@
+import { Command } from 'nest-commander';
+import { STANDARD_OBJECTS } from 'twenty-shared/metadata';
+import { doNotTranslate } from 'twenty-shared/i18n';
+import { isDefined } from 'twenty-shared/utils';
+
+import { ProvisionedWorkspaceCommandRunner } from 'src/database/commands/command-runners/provisioned-workspace.command-runner';
+import { WorkspaceIteratorService } from 'src/database/commands/command-runners/workspace-iterator.service';
+import { type RunOnWorkspaceArgs } from 'src/database/commands/command-runners/workspace.command-runner';
+import { getStandardFlatEntitiesToCreateOrThrow } from 'src/database/commands/upgrade-version-command/2-10/utils/get-standard-flat-entities-to-create-or-throw.util';
+import { ApplicationService } from 'src/engine/core-modules/application/application.service';
+import { RegisteredWorkspaceCommand } from 'src/engine/core-modules/upgrade/decorators/registered-workspace-command.decorator';
+import { findFlatEntityByUniversalIdentifier } from 'src/engine/metadata-modules/flat-entity/utils/find-flat-entity-by-universal-identifier.util';
+import { type FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';
+import { WorkspaceCacheService } from 'src/engine/workspace-cache/services/workspace-cache.service';
+import { computeTwentyStandardApplicationAllFlatEntityMaps } from 'src/engine/workspace-manager/twenty-standard-application/utils/twenty-standard-application-all-flat-entity-maps.constant';
+import { WorkspaceMigrationBuilderException } from 'src/engine/workspace-manager/workspace-migration/exceptions/workspace-migration-builder-exception';
+import { WorkspaceMigrationValidateBuildAndRunService } from 'src/engine/workspace-manager/workspace-migration/services/workspace-migration-validate-build-and-run-service';
+
+const ASSISTANT_PARTICIPANT_FIELD_UNIVERSAL_IDENTIFIER =
+ STANDARD_OBJECTS.agentChatThread.fields.isAssistantParticipant
+ .universalIdentifier;
+
+@RegisteredWorkspaceCommand('2.53.0', 1793111719062)
+@Command({
+ name: 'upgrade:2-53:add-chat-assistant-participation',
+ description: doNotTranslate(
+ 'Persist whether the assistant participates in each conversation',
+ ),
+})
+export class AddChatAssistantParticipationCommand extends ProvisionedWorkspaceCommandRunner {
+ constructor(
+ protected readonly workspaceIteratorService: WorkspaceIteratorService,
+ private readonly applicationService: ApplicationService,
+ private readonly workspaceCacheService: WorkspaceCacheService,
+ private readonly workspaceMigrationValidateBuildAndRunService: WorkspaceMigrationValidateBuildAndRunService,
+ ) {
+ super(workspaceIteratorService);
+ }
+
+ override async runOnWorkspace(args: RunOnWorkspaceArgs): Promise<void> {
+ await this.up(args);
+ }
+
+ async up({ workspaceId, options }: RunOnWorkspaceArgs): Promise<void> {
+ const { flatObjectMetadataMaps, flatFieldMetadataMaps } =
+ await this.workspaceCacheService.getOrRecompute(workspaceId, [
+ 'flatObjectMetadataMaps',
+ 'flatFieldMetadataMaps',
+ ]);
+ const threadObject =
+ flatObjectMetadataMaps.byUniversalIdentifier[
+ STANDARD_OBJECTS.agentChatThread.universalIdentifier
+ ];
+ const existingField = findFlatEntityByUniversalIdentifier<FlatFieldMetadata>({
+ flatEntityMaps: flatFieldMetadataMaps,
+ universalIdentifier: ASSISTANT_PARTICIPANT_FIELD_UNIVERSAL_IDENTIFIER,
+ });
+
+ if (!isDefined(threadObject) || isDefined(existingField)) {
+ return;
+ }
+
+ const { twentyStandardFlatApplication } =
+ await this.applicationService.findWorkspaceTwentyStandardAndCustomApplicationOrThrow(
+ { workspaceId },
+ );
+ const { allFlatEntityMaps } =
+ computeTwentyStandardApplicationAllFlatEntityMaps({
+ now: new Date().toISOString(),
+ workspaceId,
+ twentyStandardApplicationId: twentyStandardFlatApplication.id,
+ });
+ const fieldsToCreate =
+ getStandardFlatEntitiesToCreateOrThrow<FlatFieldMetadata>({
+ standardFlatEntityMaps: allFlatEntityMaps.flatFieldMetadataMaps,
+ existingFlatEntityMaps: flatFieldMetadataMaps,
+ universalIdentifiers: [
+ ASSISTANT_PARTICIPANT_FIELD_UNIVERSAL_IDENTIFIER,
+ ],
+ });
+
+ await this.migrateField({
+ workspaceId,
+ options,
+ fieldsToCreate,
+ fieldsToDelete: [],
+ });
+ }
+
+ async down({ workspaceId, options }: RunOnWorkspaceArgs): Promise<void> {
+ const { flatFieldMetadataMaps } =
+ await this.workspaceCacheService.getOrRecompute(workspaceId, [
+ 'flatFieldMetadataMaps',
+ ]);
+ const field = findFlatEntityByUniversalIdentifier<FlatFieldMetadata>({
+ flatEntityMaps: flatFieldMetadataMaps,
+ universalIdentifier: ASSISTANT_PARTICIPANT_FIELD_UNIVERSAL_IDENTIFIER,
+ });
+
+ if (!isDefined(field)) {
+ return;
+ }
+
+ await this.migrateField({
+ workspaceId,
+ options,
+ fieldsToCreate: [],
+ fieldsToDelete: [field],
+ });
+ }
+
+ private async migrateField({
+ workspaceId,
+ options,
+ fieldsToCreate,
+ fieldsToDelete,
+ }: Pick<RunOnWorkspaceArgs, 'workspaceId' | 'options'> & {
+ fieldsToCreate: FlatFieldMetadata[];
+ fieldsToDelete: FlatFieldMetadata[];
+ }): Promise<void> {
+ if (options.dryRun ?? false) {
+ this.logger.log(
+ doNotTranslate(
+ `[DRY RUN] Would create ${fieldsToCreate.length} and delete ${fieldsToDelete.length} assistant participation fields for workspace ${workspaceId}`,
+ ),
+ );
+
+ return;
+ }
+
+ const { twentyStandardFlatApplication } =
+ await this.applicationService.findWorkspaceTwentyStandardAndCustomApplicationOrThrow(
+ { workspaceId },
+ );
+ const result =
+ await this.workspaceMigrationValidateBuildAndRunService.validateBuildAndRunLegacyWorkspaceMigration(
+ {
+ workspaceId,
+ isSystemBuild: true,
+ applicationUniversalIdentifier:
+ twentyStandardFlatApplication.universalIdentifier,
+ allFlatEntityOperationByMetadataName: {
+ fieldMetadata: {
+ flatEntityToCreate: fieldsToCreate,
+ flatEntityToDelete: fieldsToDelete,
+ flatEntityToUpdate: [],
+ },
+ },
+ },
+ );
+
+ if (result.status === 'fail') {
+ throw new WorkspaceMigrationBuilderException(
+ result,
+ doNotTranslate(
+ `Failed to migrate assistant participation for workspace ${workspaceId}`,
+ ),
+ );
+ }
+ }
+}
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/workspace-command-provider.module.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/workspace-command-provider.module.ts
index 4932f6d665f..ec2724f576f 100644
--- a/packages/twenty-server/src/database/commands/upgrade-version-command/workspace-command-provider.module.ts
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/workspace-command-provider.module.ts
@@ -45,6 +45,7 @@ import { V2_49_UpgradeVersionCommandModule } from 'src/database/commands/upgrade
import { V2_50_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-50/2-50-upgrade-version-command.module';
import { V2_51_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-51/2-51-upgrade-version-command.module';
import { V2_52_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-52/2-52-upgrade-version-command.module';
+import { V2_53_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-53/2-53-upgrade-version-command.module';
import { V2_4_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-4/2-4-upgrade-version-command.module';
import { V2_5_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-5/2-5-upgrade-version-command.module';
import { V2_7_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-version-command/2-7/2-7-upgrade-version-command.module';
@@ -103,6 +104,7 @@ import { V2_9_UpgradeVersionCommandModule } from 'src/database/commands/upgrade-
V2_50_UpgradeVersionCommandModule,
V2_51_UpgradeVersionCommandModule,
V2_52_UpgradeVersionCommandModule,
+ V2_53_UpgradeVersionCommandModule,
],
})
export class WorkspaceCommandProviderModule {}
diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-history/standard-objects/agent-chat-thread.workspace-entity.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-history/standard-objects/agent-chat-thread.workspace-entity.ts
index 66b140ab969..4fc3d538798 100644
--- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-history/standard-objects/agent-chat-thread.workspace-entity.ts
+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-history/standard-objects/agent-chat-thread.workspace-entity.ts
@@ -24,6 +24,7 @@ export class AgentChatThreadWorkspaceEntity extends BaseWorkspaceEntity {
channelArchivedAt: string | null;
channelSnoozedUntil: string | null;
title: string | null;
+ isAssistantParticipant: boolean;
lastActivityAt: string | null;
lastMessageText: string | null;
lastMessageSenderWorkspaceMemberId: string | null;
diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/__snapshots__/get-standard-object-metadata-related-entity-ids.util.spec.ts.snap b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/__snapshots__/get-standard-object-metadata-related-entity-ids.util.spec.ts.snap
index cc164951b00..1d6b4ea0bf3 100644
--- a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/__snapshots__/get-standard-object-metadata-related-entity-ids.util.spec.ts.snap
+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/__tests__/__snapshots__/get-standard-object-metadata-related-entity-ids.util.spec.ts.snap
@@ -5,31 +5,31 @@ exports[`getStandardObjectMetadataRelatedEntityIds should return standard object
"agentChatThread": {
"fields": {
"activeStreamId": {
- "id": "00000000-0000-0000-0000-000000001049",
+ "id": "00000000-0000-0000-0000-000000001050",
},
"archivedAt": {
"id": "00000000-0000-0000-0000-000000001038",
},
"assignee": {
- "id": "00000000-0000-0000-0000-000000001056",
+ "id": "00000000-0000-0000-0000-000000001057",
},
"attachments": {
- "id": "00000000-0000-0000-0000-000000001053",
+ "id": "00000000-0000-0000-0000-000000001054",
},
"channelArchivedAt": {
- "id": "00000000-0000-0000-0000-000000001058",
+ "id": "00000000-0000-0000-0000-000000001059",
},
"channelId": {
- "id": "00000000-0000-0000-0000-000000001057",
+ "id": "00000000-0000-0000-0000-000000001058",
},
"channelSnoozedUntil": {
- "id": "00000000-0000-0000-0000-000000001059",
+ "id": "00000000-0000-0000-0000-000000001060",
},
"contextWindowTokens": {
- "id": "00000000-0000-0000-0000-000000001043",
+ "id": "00000000-0000-0000-0000-000000001044",
},
"conversationSize": {
- "id": "00000000-0000-0000-0000-000000001044",
+ "id": "00000000-0000-0000-0000-000000001045",
},
"createdAt": {
"id": "00000000-0000-0000-0000-000000001035",
@@ -40,50 +40,53 @@ exports[`getStandardObjectMetadataRelatedEntityIds should return standard object
"id": {
"id": "00000000-0000-0000-0000-000000001034",
},
+ "isAssistantParticipant": {
+ "id": "00000000-0000-0000-0000-000000001041",
+ },
"lastActivityAt": {
- "id": "00000000-0000-0000-0000-000000001060",
+ "id": "00000000-0000-0000-0000-000000001061",
},
"lastMessageSenderWorkspaceMemberId": {
- "id": "00000000-0000-0000-0000-000000001062",
+ "id": "00000000-0000-0000-0000-000000001063",
},
"lastMessageText": {
- "id": "00000000-0000-0000-0000-000000001061",
+ "id": "00000000-0000-0000-0000-000000001062",
},
"messages": {
- "id": "00000000-0000-0000-0000-000000001052",
+ "id": "00000000-0000-0000-0000-000000001053",
},
"participants": {
- "id": "00000000-0000-0000-0000-000000001055",
+ "id": "00000000-0000-0000-0000-000000001056",
},
"pendingQuestionMessageId": {
- "id": "00000000-0000-0000-0000-000000001050",
+ "id": "00000000-0000-0000-0000-000000001051",
},
"recordTargets": {
- "id": "00000000-0000-0000-0000-000000001054",
+ "id": "00000000-0000-0000-0000-000000001055",
},
"title": {
"id": "00000000-0000-0000-0000-000000001040",
},
"totalCacheCreationTokens": {
- "id": "00000000-0000-0000-0000-000000001048",
+ "id": "00000000-0000-0000-0000-000000001049",
},
"totalCacheReadTokens": {
- "id": "00000000-0000-0000-0000-000000001047",
+ "id": "00000000-0000-0000-0000-000000001048",
},
"totalInputCredits": {
- "id": "00000000-0000-0000-0000-000000001045",
+ "id": "00000000-0000-0000-0000-000000001046",
},
"totalInputTokens": {
- "id": "00000000-0000-0000-0000-000000001041",
+ "id": "00000000-0000-0000-0000-000000001042",
},
"totalOutputCredits": {
- "id": "00000000-0000-0000-0000-000000001046",
+ "id": "00000000-0000-0000-0000-000000001047",
},
"totalOutputTokens": {
- "id": "00000000-0000-0000-0000-000000001042",
+ "id": "00000000-0000-0000-0000-000000001043",
},
"turns": {
- "id": "00000000-0000-0000-0000-000000001051",
+ "id": "00000000-0000-0000-0000-000000001052",
},
"updatedAt": {
"id": "00000000-0000-0000-0000-000000001036",
@@ -92,310 +95,310 @@ exports[`getStandardObjectMetadataRelatedEntityIds should return standard object
"id": "00000000-0000-0000-0000-000000001039",
},
"writerWorkspaceMemberIds": {
- "id": "00000000-0000-0000-0000-000000001063",
+ "id": "00000000-0000-0000-0000-000000001064",
},
},
- "id": "00000000-0000-0000-0000-000000001064",
+ "id": "00000000-0000-0000-0000-000000001065",
"views": undefined,
},
"agentChatThreadParticipant": {
"fields": {
"archivedAt": {
- "id": "00000000-0000-0000-0000-000000001072",
+ "id": "00000000-0000-0000-0000-000000001073",
},
"createdAt": {
- "id": "00000000-0000-0000-0000-000000001066",
+ "id": "00000000-0000-0000-0000-000000001067",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000001068",
+ "id": "00000000-0000-0000-0000-000000001069",
},
"id": {
- "id": "00000000-0000-0000-0000-000000001065",
+ "id": "00000000-0000-0000-0000-000000001066",
},
"isSubscribed": {
- "id": "00000000-0000-0000-0000-000000001074",
+ "id": "00000000-0000-0000-0000-000000001075",
},
"lastMentionedAt": {
- "id": "00000000-0000-0000-0000-000000001075",
+ "id": "00000000-0000-0000-0000-000000001076",
},
"lastReadAt": {
- "id": "00000000-0000-0000-0000-000000001071",
+ "id": "00000000-0000-0000-0000-000000001072",
},
"snoozedUntil": {
- "id": "00000000-0000-0000-0000-000000001073",
+ "id": "00000000-0000-0000-0000-000000001074",
},
"thread": {
- "id": "00000000-0000-0000-0000-000000001069",
+ "id": "00000000-0000-0000-0000-000000001070",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000001067",
+ "id": "00000000-0000-0000-0000-000000001068",
},
"workspaceMember": {
- "id": "00000000-0000-0000-0000-000000001070",
+ "id": "00000000-0000-0000-0000-000000001071",
},
},
- "id": "00000000-0000-0000-0000-000000001076",
+ "id": "00000000-0000-0000-0000-000000001077",
"views": undefined,
},
"agentChatThreadTarget": {
"fields": {
"createdAt": {
- "id": "00000000-0000-0000-0000-000000001079",
+ "id": "00000000-0000-0000-0000-000000001080",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000001081",
+ "id": "00000000-0000-0000-0000-000000001082",
},
"id": {
- "id": "00000000-0000-0000-0000-000000001078",
+ "id": "00000000-0000-0000-0000-000000001079",
},
"target": {
- "id": "00000000-0000-0000-0000-000000001077",
+ "id": "00000000-0000-0000-0000-000000001078",
},
"targetCompany": {
- "id": "00000000-0000-0000-0000-000000001084",
+ "id": "00000000-0000-0000-0000-000000001085",
},
"targetOpportunity": {
- "id": "00000000-0000-0000-0000-000000001085",
+ "id": "00000000-0000-0000-0000-000000001086",
},
"targetPerson": {
- "id": "00000000-0000-0000-0000-000000001083",
+ "id": "00000000-0000-0000-0000-000000001084",
},
"thread": {
- "id": "00000000-0000-0000-0000-000000001082",
+ "id": "00000000-0000-0000-0000-000000001083",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000001080",
+ "id": "00000000-0000-0000-0000-000000001081",
},
},
- "id": "00000000-0000-0000-0000-000000001086",
+ "id": "00000000-0000-0000-0000-000000001087",
"views": {},
},
"agentMessage": {
"fields": {
"agentId": {
- "id": "00000000-0000-0000-0000-000000001111",
+ "id": "00000000-0000-0000-0000-000000001112",
},
"createdAt": {
- "id": "00000000-0000-0000-0000-000000001108",
+ "id": "00000000-0000-0000-0000-000000001109",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000001110",
+ "id": "00000000-0000-0000-0000-000000001111",
},
"id": {
- "id": "00000000-0000-0000-0000-000000001107",
+ "id": "00000000-0000-0000-0000-000000001108",
},
"parts": {
- "id": "00000000-0000-0000-0000-000000001119",
+ "id": "00000000-0000-0000-0000-000000001120",
},
"processedAt": {
- "id": "00000000-0000-0000-0000-000000001116",
+ "id": "00000000-0000-0000-0000-000000001117",
},
"reactions": {
- "id": "00000000-0000-0000-0000-000000001120",
+ "id": "00000000-0000-0000-0000-000000001121",
},
"role": {
- "id": "00000000-0000-0000-0000-000000001114",
+ "id": "00000000-0000-0000-0000-000000001115",
},
"senderApplicationId": {
- "id": "00000000-0000-0000-0000-000000001113",
+ "id": "00000000-0000-0000-0000-000000001114",
},
"senderWorkspaceMember": {
- "id": "00000000-0000-0000-0000-000000001112",
+ "id": "00000000-0000-0000-0000-000000001113",
},
"status": {
- "id": "00000000-0000-0000-0000-000000001115",
+ "id": "00000000-0000-0000-0000-000000001116",
},
"thread": {
- "id": "00000000-0000-0000-0000-000000001117",
+ "id": "00000000-0000-0000-0000-000000001118",
},
"turn": {
- "id": "00000000-0000-0000-0000-000000001118",
+ "id": "00000000-0000-0000-0000-000000001119",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000001109",
+ "id": "00000000-0000-0000-0000-000000001110",
},
},
- "id": "00000000-0000-0000-0000-000000001121",
+ "id": "00000000-0000-0000-0000-000000001122",
"views": undefined,
},
"agentMessagePart": {
"fields": {
"createdAt": {
- "id": "00000000-0000-0000-0000-000000001132",
+ "id": "00000000-0000-0000-0000-000000001133",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000001134",
+ "id": "00000000-0000-0000-0000-000000001135",
},
"errorDetails": {
- "id": "00000000-0000-0000-0000-000000001146",
+ "id": "00000000-0000-0000-0000-000000001147",
},
"errorMessage": {
- "id": "00000000-0000-0000-0000-000000001145",
+ "id": "00000000-0000-0000-0000-000000001146",
},
"fileFilename": {
- "id": "00000000-0000-0000-0000-000000001154",
+ "id": "00000000-0000-0000-0000-000000001155",
},
"fileId": {
- "id": "00000000-0000-0000-0000-000000001155",
+ "id": "00000000-0000-0000-0000-000000001156",
},
"id": {
- "id": "00000000-0000-0000-0000-000000001131",
+ "id": "00000000-0000-0000-0000-000000001132",
},
"message": {
- "id": "00000000-0000-0000-0000-000000001157",
+ "id": "00000000-0000-0000-0000-000000001158",
},
"orderIndex": {
- "id": "00000000-0000-0000-0000-000000001135",
+ "id": "00000000-0000-0000-0000-000000001136",
},
"providerExecuted": {
- "id": "00000000-0000-0000-0000-000000001144",
+ "id": "00000000-0000-0000-0000-000000001145",
},
"providerMetadata": {
- "id": "00000000-0000-0000-0000-000000001156",
+ "id": "00000000-0000-0000-0000-000000001157",
},
"reasoningContent": {
- "id": "00000000-0000-0000-0000-000000001138",
+ "id": "00000000-0000-0000-0000-000000001139",
},
"sourceDocumentFilename": {
- "id": "00000000-0000-0000-0000-000000001153",
+ "id": "00000000-0000-0000-0000-000000001154",
},
"sourceDocumentMediaType": {
- "id": "00000000-0000-0000-0000-000000001151",
+ "id": "00000000-0000-0000-0000-000000001152",
},
"sourceDocumentSourceId": {
- "id": "00000000-0000-0000-0000-000000001150",
+ "id": "00000000-0000-0000-0000-000000001151",
},
"sourceDocumentTitle": {
- "id": "00000000-0000-0000-0000-000000001152",
+ "id": "00000000-0000-0000-0000-000000001153",
},
"sourceUrlSourceId": {
- "id": "00000000-0000-0000-0000-000000001147",
+ "id": "00000000-0000-0000-0000-000000001148",
},
"sourceUrlTitle": {
- "id": "00000000-0000-0000-0000-000000001149",
+ "id": "00000000-0000-0000-0000-000000001150",
},
"sourceUrlUrl": {
- "id": "00000000-0000-0000-0000-000000001148",
+ "id": "00000000-0000-0000-0000-000000001149",
},
"state": {
- "id": "00000000-0000-0000-0000-000000001143",
+ "id": "00000000-0000-0000-0000-000000001144",
},
"textContent": {
- "id": "00000000-0000-0000-0000-000000001137",
+ "id": "00000000-0000-0000-0000-000000001138",
},
"toolCallId": {
- "id": "00000000-0000-0000-0000-000000001140",
+ "id": "00000000-0000-0000-0000-000000001141",
},
"toolInput": {
- "id": "00000000-0000-0000-0000-000000001141",
+ "id": "00000000-0000-0000-0000-000000001142",
},
"toolName": {
- "id": "00000000-0000-0000-0000-000000001139",
+ "id": "00000000-0000-0000-0000-000000001140",
},
"toolOutput": {
- "id": "00000000-0000-0000-0000-000000001142",
+ "id": "00000000-0000-0000-0000-000000001143",
},
"type": {
- "id": "00000000-0000-0000-0000-000000001136",
+ "id": "00000000-0000-0000-0000-000000001137",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000001133",
+ "id": "00000000-0000-0000-0000-000000001134",
},
},
- "id": "00000000-0000-0000-0000-000000001158",
+ "id": "00000000-0000-0000-0000-000000001159",
"views": undefined,
},
"agentMessageReaction": {
"fields": {
"agentId": {
- "id": "00000000-0000-0000-0000-000000001128",
+ "id": "00000000-0000-0000-0000-000000001129",
},
"createdAt": {
- "id": "00000000-0000-0000-0000-000000001123",
+ "id": "00000000-0000-0000-0000-000000001124",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000001125",
+ "id": "00000000-0000-0000-0000-000000001126",
},
"emoji": {
- "id": "00000000-0000-0000-0000-000000001129",
+ "id": "00000000-0000-0000-0000-000000001130",
},
"id": {
- "id": "00000000-0000-0000-0000-000000001122",
+ "id": "00000000-0000-0000-0000-000000001123",
},
"message": {
- "id": "00000000-0000-0000-0000-000000001126",
+ "id": "00000000-0000-0000-0000-000000001127",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000001124",
+ "id": "00000000-0000-0000-0000-000000001125",
},
"workspaceMember": {
- "id": "00000000-0000-0000-0000-000000001127",
+ "id": "00000000-0000-0000-0000-000000001128",
},
},
- "id": "00000000-0000-0000-0000-000000001130",
+ "id": "00000000-0000-0000-0000-000000001131",
"views": undefined,
},
"agentTurn": {
"fields": {
"agentId": {
- "id": "00000000-0000-0000-0000-000000001091",
+ "id": "00000000-0000-0000-0000-000000001092",
},
"cacheCreationTokens": {
- "id": "00000000-0000-0000-0000-000000001102",
+ "id": "00000000-0000-0000-0000-000000001103",
},
"cacheReadTokens": {
- "id": "00000000-0000-0000-0000-000000001101",
+ "id": "00000000-0000-0000-0000-000000001102",
},
"createdAt": {
- "id": "00000000-0000-0000-0000-000000001088",
+ "id": "00000000-0000-0000-0000-000000001089",
},
"createdBy": {
- "id": "00000000-0000-0000-0000-000000001105",
+ "id": "00000000-0000-0000-0000-000000001106",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000001090",
+ "id": "00000000-0000-0000-0000-000000001091",
},
"endedAt": {
- "id": "00000000-0000-0000-0000-000000001097",
+ "id": "00000000-0000-0000-0000-000000001098",
},
"error": {
- "id": "00000000-0000-0000-0000-000000001095",
+ "id": "00000000-0000-0000-0000-000000001096",
},
"id": {
- "id": "00000000-0000-0000-0000-000000001087",
+ "id": "00000000-0000-0000-0000-000000001088",
},
"inputCredits": {
- "id": "00000000-0000-0000-0000-000000001103",
+ "id": "00000000-0000-0000-0000-000000001104",
},
"inputTokens": {
- "id": "00000000-0000-0000-0000-000000001099",
+ "id": "00000000-0000-0000-0000-000000001100",
},
"messages": {
- "id": "00000000-0000-0000-0000-000000001093",
+ "id": "00000000-0000-0000-0000-000000001094",
},
"modelId": {
- "id": "00000000-0000-0000-0000-000000001098",
+ "id": "00000000-0000-0000-0000-000000001099",
},
"outputCredits": {
- "id": "00000000-0000-0000-0000-000000001104",
+ "id": "00000000-0000-0000-0000-000000001105",
},
"outputTokens": {
- "id": "00000000-0000-0000-0000-000000001100",
+ "id": "00000000-0000-0000-0000-000000001101",
},
"startedAt": {
- "id": "00000000-0000-0000-0000-000000001096",
+ "id": "00000000-0000-0000-0000-000000001097",
},
"status": {
- "id": "00000000-0000-0000-0000-000000001094",
+ "id": "00000000-0000-0000-0000-000000001095",
},
"thread": {
- "id": "00000000-0000-0000-0000-000000001092",
+ "id": "00000000-0000-0000-0000-000000001093",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000001089",
+ "id": "00000000-0000-0000-0000-000000001090",
},
},
- "id": "00000000-0000-0000-0000-000000001106",
+ "id": "00000000-0000-0000-0000-000000001107",
"views": undefined,
},
"attachment": {
@@ -1159,64 +1162,64 @@ exports[`getStandardObjectMetadataRelatedEntityIds should return standard object
"campaignDelivery": {
"fields": {
"bouncedAt": {
- "id": "00000000-0000-0000-0000-000000001174",
+ "id": "00000000-0000-0000-0000-000000001175",
},
"campaignId": {
- "id": "00000000-0000-0000-0000-000000001163",
+ "id": "00000000-0000-0000-0000-000000001164",
},
"claimExpiresAt": {
- "id": "00000000-0000-0000-0000-000000001170",
+ "id": "00000000-0000-0000-0000-000000001171",
},
"claimToken": {
- "id": "00000000-0000-0000-0000-000000001169",
+ "id": "00000000-0000-0000-0000-000000001170",
},
"complainedAt": {
- "id": "00000000-0000-0000-0000-000000001175",
+ "id": "00000000-0000-0000-0000-000000001176",
},
"createdAt": {
- "id": "00000000-0000-0000-0000-000000001160",
+ "id": "00000000-0000-0000-0000-000000001161",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000001162",
+ "id": "00000000-0000-0000-0000-000000001163",
},
"deliveredAt": {
- "id": "00000000-0000-0000-0000-000000001173",
+ "id": "00000000-0000-0000-0000-000000001174",
},
"failureReason": {
- "id": "00000000-0000-0000-0000-000000001168",
+ "id": "00000000-0000-0000-0000-000000001169",
},
"id": {
- "id": "00000000-0000-0000-0000-000000001159",
+ "id": "00000000-0000-0000-0000-000000001160",
},
"personId": {
- "id": "00000000-0000-0000-0000-000000001164",
+ "id": "00000000-0000-0000-0000-000000001165",
},
"providerMessageId": {
- "id": "00000000-0000-0000-0000-000000001171",
+ "id": "00000000-0000-0000-0000-000000001172",
},
"recipientEmail": {
- "id": "00000000-0000-0000-0000-000000001165",
+ "id": "00000000-0000-0000-0000-000000001166",
},
"rejectedAt": {
- "id": "00000000-0000-0000-0000-000000001176",
+ "id": "00000000-0000-0000-0000-000000001177",
},
"renderingFailedAt": {
- "id": "00000000-0000-0000-0000-000000001177",
+ "id": "00000000-0000-0000-0000-000000001178",
},
"sentAt": {
- "id": "00000000-0000-0000-0000-000000001172",
+ "id": "00000000-0000-0000-0000-000000001173",
},
"skipReason": {
- "id": "00000000-0000-0000-0000-000000001167",
+ "id": "00000000-0000-0000-0000-000000001168",
},
"state": {
- "id": "00000000-0000-0000-0000-000000001166",
+ "id": "00000000-0000-0000-0000-000000001167",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000001161",
+ "id": "00000000-0000-0000-0000-000000001162",
},
},
- "id": "00000000-0000-0000-0000-000000001178",
+ "id": "00000000-0000-0000-0000-000000001179",
"views": undefined,
},
"company": {
@@ -2213,34 +2216,34 @@ exports[`getStandardObjectMetadataRelatedEntityIds should return standard object
"messageSuppression": {
"fields": {
"createdAt": {
- "id": "00000000-0000-0000-0000-000000001180",
+ "id": "00000000-0000-0000-0000-000000001181",
},
"deletedAt": {
- "id": "00000000-0000-0000-0000-000000001182",
+ "id": "00000000-0000-0000-0000-000000001183",
},
"emailAddress": {
- "id": "00000000-0000-0000-0000-000000001183",
+ "id": "00000000-0000-0000-0000-000000001184",
},
"id": {
- "id": "00000000-0000-0000-0000-000000001179",
+ "id": "00000000-0000-0000-0000-000000001180",
},
"providerEventId": {
- "id": "00000000-0000-0000-0000-000000001186",
+ "id": "00000000-0000-0000-0000-000000001187",
},
"reason": {
- "id": "00000000-0000-0000-0000-000000001184",
+ "id": "00000000-0000-0000-0000-000000001185",
},
"source": {
- "id": "00000000-0000-0000-0000-000000001185",
+ "id": "00000000-0000-0000-0000-000000001186",
},
"unsubscribeTopicId": {
- "id": "00000000-0000-0000-0000-000000001187",
+ "id": "00000000-0000-0000-0000-000000001188",
},
"updatedAt": {
- "id": "00000000-0000-0000-0000-000000001181",
+ "id": "00000000-0000-0000-0000-000000001182",
},
},
- "id": "00000000-0000-0000-0000-000000001188",
+ "id": "00000000-0000-0000-0000-000000001189",
"views": undefined,
},
"messageThread": {
diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/compute-agent-chat-thread-standard-flat-field-metadata.util.ts b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/compute-agent-chat-thread-standard-flat-field-metadata.util.ts
index 1e2c0d2e7a2..21cf94a5dc9 100644
--- a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/compute-agent-chat-thread-standard-flat-field-metadata.util.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/field-metadata/compute-agent-chat-thread-standard-flat-field-metadata.util.ts
@@ -67,6 +67,34 @@ export const buildAgentChatThreadStandardFlatFieldMetadatas = (
writability: MetadataWritability.OPEN,
isAuditLogged: false,
},
+ isAssistantParticipant: {
+ ...createStandardFieldFlatMetadata({
+ ...args,
+ context: {
+ fieldName: 'isAssistantParticipant',
+ type: FieldMetadataType.BOOLEAN,
+ label: i18nLabel(
+ msg({
+ message: 'Assistant participant',
+ context: 'fieldMetadata.label',
+ }),
+ ),
+ description: i18nLabel(
+ msg({
+ message: 'Whether the assistant participates in this conversation',
+ context: 'fieldMetadata.description',
+ }),
+ ),
+ icon: 'IconSparkles',
+ isSystem: true,
+ isUIEditable: false,
+ isNullable: false,
+ defaultValue: true,
+ },
+ }),
+ writability: MetadataWritability.SYSTEM,
+ isAuditLogged: false,
+ },
totalInputTokens: {
...createStandardFieldFlatMetadata({
...args,
diff --git a/packages/twenty-shared/src/metadata/__tests__/__snapshots__/standardObjectUniversalIdentifiers.test.ts.snap b/packages/twenty-shared/src/metadata/__tests__/__snapshots__/standardObjectUniversalIdentifiers.test.ts.snap
index 88ce785ee80..10276165e8f 100644
--- a/packages/twenty-shared/src/metadata/__tests__/__snapshots__/standardObjectUniversalIdentifiers.test.ts.snap
+++ b/packages/twenty-shared/src/metadata/__tests__/__snapshots__/standardObjectUniversalIdentifiers.test.ts.snap
@@ -40,6 +40,9 @@ exports[`STANDARD_OBJECTS universal identifiers should never change without an e
"id": {
"universalIdentifier": "59b74693-2b88-5eb9-82ef-23b1e75c2b78",
},
+ "isAssistantParticipant": {
+ "universalIdentifier": "d901f5bc-23ba-48ac-9103-145da4b76afe",
+ },
"lastActivityAt": {
"universalIdentifier": "b3847509-8e98-4038-88de-dd891767d6fc",
},
diff --git a/packages/twenty-shared/src/metadata/constants/standard-object-fields.constant.ts b/packages/twenty-shared/src/metadata/constants/standard-object-fields.constant.ts
index 52fe9a0dbd4..f5400742548 100644
--- a/packages/twenty-shared/src/metadata/constants/standard-object-fields.constant.ts
+++ b/packages/twenty-shared/src/metadata/constants/standard-object-fields.constant.ts
@@ -17,6 +17,9 @@ export const STANDARD_OBJECT_FIELDS = {
universalIdentifier: '6f3ed3b5-0642-4a2a-9558-98376adb60f4',
},
title: { universalIdentifier: '9283c05e-127c-46ec-82e9-6424a7c0a2f1' },
+ isAssistantParticipant: {
+ universalIdentifier: 'd901f5bc-23ba-48ac-9103-145da4b76afe',
+ },
totalInputTokens: {
universalIdentifier: '2705f4af-24b8-4660-a8a8-8eff689298d1',
},