Skip to content

The open alternative to Salesforce, designed for AI.

fix(server): unblock the server typecheck that times out on every PR (#27351)

Félix Malfait9912f3d3813e
diff --git a/.github/workflows/ci-client-sdk.yaml b/.github/workflows/ci-client-sdk.yaml
index b57ef91e349..c56876b7c3b 100644
--- a/.github/workflows/ci-client-sdk.yaml
+++ b/.github/workflows/ci-client-sdk.yaml
@@ -51,5 +51,5 @@ jobs:
needs: [changed-files-check, client-sdk-test]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-create-app-e2e-minimal.yaml b/.github/workflows/ci-create-app-e2e-minimal.yaml
index 4c68afff516..23bdc3fd102 100644
--- a/.github/workflows/ci-create-app-e2e-minimal.yaml
+++ b/.github/workflows/ci-create-app-e2e-minimal.yaml
@@ -216,5 +216,5 @@ jobs:
needs: [changed-files-check, create-app-e2e-minimal]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-create-app.yaml b/.github/workflows/ci-create-app.yaml
index 02295d638bf..a822ce5326a 100644
--- a/.github/workflows/ci-create-app.yaml
+++ b/.github/workflows/ci-create-app.yaml
@@ -50,5 +50,5 @@ jobs:
needs: [changed-files-check, create-app-test]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-e2e-main.yaml b/.github/workflows/ci-e2e-main.yaml
index eb7b18a1fc8..bdef81e9b2c 100644
--- a/.github/workflows/ci-e2e-main.yaml
+++ b/.github/workflows/ci-e2e-main.yaml
@@ -427,7 +427,7 @@ jobs:
needs: [e2e-test]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
notify-main-ci-failure:
diff --git a/.github/workflows/ci-emails.yaml b/.github/workflows/ci-emails.yaml
index 68e8e549d42..cd53f26ae88 100644
--- a/.github/workflows/ci-emails.yaml
+++ b/.github/workflows/ci-emails.yaml
@@ -64,5 +64,5 @@ jobs:
needs: [changed-files-check, emails-test]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-example-app-hello-world.yaml b/.github/workflows/ci-example-app-hello-world.yaml
index 1a9fb48e90b..93e1feaa90e 100644
--- a/.github/workflows/ci-example-app-hello-world.yaml
+++ b/.github/workflows/ci-example-app-hello-world.yaml
@@ -90,5 +90,5 @@ jobs:
needs: [changed-files-check, example-app-hello-world]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-example-app-postcard.yaml b/.github/workflows/ci-example-app-postcard.yaml
index ab4ac47dc5f..9c79c9290a5 100644
--- a/.github/workflows/ci-example-app-postcard.yaml
+++ b/.github/workflows/ci-example-app-postcard.yaml
@@ -117,5 +117,5 @@ jobs:
needs: [changed-files-check, example-app-postcard]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-front-component-renderer.yaml b/.github/workflows/ci-front-component-renderer.yaml
index 58627a44f20..7c7cfe3299a 100644
--- a/.github/workflows/ci-front-component-renderer.yaml
+++ b/.github/workflows/ci-front-component-renderer.yaml
@@ -111,5 +111,5 @@ jobs:
]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-front.yaml b/.github/workflows/ci-front.yaml
index abe92642f31..bd95779ffdf 100644
--- a/.github/workflows/ci-front.yaml
+++ b/.github/workflows/ci-front.yaml
@@ -270,5 +270,5 @@ jobs:
]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-knip.yaml b/.github/workflows/ci-knip.yaml
index 408b60c3e83..8fc929d5271 100644
--- a/.github/workflows/ci-knip.yaml
+++ b/.github/workflows/ci-knip.yaml
@@ -49,5 +49,5 @@ jobs:
needs: [changed-files-check, knip]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-sdk.yaml b/.github/workflows/ci-sdk.yaml
index d441b93f83d..da74d5aa568 100644
--- a/.github/workflows/ci-sdk.yaml
+++ b/.github/workflows/ci-sdk.yaml
@@ -105,5 +105,5 @@ jobs:
needs: [changed-files-check, sdk-test, sdk-e2e-test]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-server.yaml b/.github/workflows/ci-server.yaml
index a2bb48b7cd4..df2ea13696a 100644
--- a/.github/workflows/ci-server.yaml
+++ b/.github/workflows/ci-server.yaml
@@ -416,5 +416,5 @@ jobs:
]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-shared.yaml b/.github/workflows/ci-shared.yaml
index e2af8d9eb87..2b66b59824a 100644
--- a/.github/workflows/ci-shared.yaml
+++ b/.github/workflows/ci-shared.yaml
@@ -47,5 +47,5 @@ jobs:
needs: [changed-files-check, shared-test]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-test-docker-compose.yaml b/.github/workflows/ci-test-docker-compose.yaml
index 5d5e4a1fb0e..e7575637935 100644
--- a/.github/workflows/ci-test-docker-compose.yaml
+++ b/.github/workflows/ci-test-docker-compose.yaml
@@ -179,5 +179,5 @@ jobs:
needs: [changed-files-check, test-compose, test-app-dev]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-twenty-apps.yaml b/.github/workflows/ci-twenty-apps.yaml
index a50c115553f..e7c854b887f 100644
--- a/.github/workflows/ci-twenty-apps.yaml
+++ b/.github/workflows/ci-twenty-apps.yaml
@@ -111,5 +111,5 @@ jobs:
needs: [discover, ci, integration]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-ui.yaml b/.github/workflows/ci-ui.yaml
index 95b303cd068..5181a752be5 100644
--- a/.github/workflows/ci-ui.yaml
+++ b/.github/workflows/ci-ui.yaml
@@ -107,5 +107,5 @@ jobs:
needs: [changed-files-check, ui-task, ui-sb-build, ui-sb-test]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-utils-test.yaml b/.github/workflows/ci-utils-test.yaml
index a662faa33fe..e8b2611f641 100644
--- a/.github/workflows/ci-utils-test.yaml
+++ b/.github/workflows/ci-utils-test.yaml
@@ -41,5 +41,5 @@ jobs:
needs: [changed-files-check, utils-test]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-website.yaml b/.github/workflows/ci-website.yaml
index 6de5d459474..708bfea5436 100644
--- a/.github/workflows/ci-website.yaml
+++ b/.github/workflows/ci-website.yaml
@@ -51,5 +51,5 @@ jobs:
needs: [changed-files-check, website-task]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/.github/workflows/ci-zapier.yaml b/.github/workflows/ci-zapier.yaml
index 2b3bc56fefe..3a39c393e21 100644
--- a/.github/workflows/ci-zapier.yaml
+++ b/.github/workflows/ci-zapier.yaml
@@ -117,5 +117,5 @@ jobs:
needs: [changed-files-check, zapier-test]
steps:
- name: Fail job if any needs failed
- if: contains(needs.*.result, 'failure')
+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
diff --git a/packages/twenty-server/src/database/commands/agent-history/__tests__/agent-history-migration.postgres.spec.ts b/packages/twenty-server/src/database/commands/agent-history/__tests__/agent-history-migration.postgres.spec.ts
index 5aaa8c646c2..6fd06f5d260 100644
--- a/packages/twenty-server/src/database/commands/agent-history/__tests__/agent-history-migration.postgres.spec.ts
+++ b/packages/twenty-server/src/database/commands/agent-history/__tests__/agent-history-migration.postgres.spec.ts
@@ -229,6 +229,7 @@ const SCHEMA = getWorkspaceSchemaName(WORKSPACE_ID);
new AgentHistoryTransactionService(workspaceStorage, orm as never),
),
chatThreadService,
+ {} as never,
);
const createActorService = (messageRepository: typeof messages) =>
diff --git a/packages/twenty-server/src/engine/core-modules/usage-limit/services/usage-limit-quota.service.ts b/packages/twenty-server/src/engine/core-modules/usage-limit/services/usage-limit-quota.service.ts
index b5ffb089ac3..80ef659e4aa 100644
--- a/packages/twenty-server/src/engine/core-modules/usage-limit/services/usage-limit-quota.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/usage-limit/services/usage-limit-quota.service.ts
@@ -505,8 +505,10 @@ export class UsageLimitQuotaService implements OnModuleInit {
.reduce(
(total, event) =>
total +
- fromRecordUsageInputToUsageConsumptionRow(event)
- .creditsUsedMicro,
+ Number(
+ fromRecordUsageInputToUsageConsumptionRow(event)
+ .creditsUsedMicro,
+ ),
0,
),
});
diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-agent-runs/utils/map-agent-turn-to-agent-run.util.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-agent-runs/utils/map-agent-turn-to-agent-run.util.ts
index 31984978a0e..2350234ea85 100644
--- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-agent-runs/utils/map-agent-turn-to-agent-run.util.ts
+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-agent-runs/utils/map-agent-turn-to-agent-run.util.ts
@@ -84,7 +84,7 @@ export const mapAgentTurnToAgentRun = (
const inputMessages = messages.filter(
(message) => !isDefined(message.agentId),
);
- const lastAgentMessage = agentMessages.at(-1);
+ const lastAgentMessage = agentMessages[agentMessages.length - 1];
return {
id: turn.id,
diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/resolvers/__tests__/agent-chat.resolver.sharing.spec.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/resolvers/__tests__/agent-chat.resolver.sharing.spec.ts
index 65cb75ecdd9..2530ea503c8 100644
--- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/resolvers/__tests__/agent-chat.resolver.sharing.spec.ts
+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/resolvers/__tests__/agent-chat.resolver.sharing.spec.ts
@@ -77,6 +77,7 @@ const buildResolver = () => {
recordEvents as never,
{} as never,
threadService,
+ {} as never,
);
const streaming = {
streamAgentChat: jest
@@ -96,6 +97,7 @@ const buildResolver = () => {
redis as never,
{} as never,
recordEvents as never,
+ {} as never,
);
const resolver = new AgentChatResolver(
chatService,
diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/services/__tests__/agent-chat-streaming.service.sender.spec.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/services/__tests__/agent-chat-streaming.service.sender.spec.ts
index 93da7489c82..1b6757c256c 100644
--- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/services/__tests__/agent-chat-streaming.service.sender.spec.ts
+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/services/__tests__/agent-chat-streaming.service.sender.spec.ts
@@ -62,6 +62,7 @@ const build = () => {
findPendingForThread: jest.fn().mockResolvedValue([]),
hasPendingForThread: jest.fn().mockResolvedValue(false),
} as never,
+ {} as never,
);
return { service, threads, queue, chat, actors, heartbeat };
};
diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/services/__tests__/agent-chat.service.thread-contexts.spec.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/services/__tests__/agent-chat.service.thread-contexts.spec.ts
index 234b1662c90..6c30ba2bde5 100644
--- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/services/__tests__/agent-chat.service.thread-contexts.spec.ts
+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/services/__tests__/agent-chat.service.thread-contexts.spec.ts
@@ -35,6 +35,7 @@ const buildService = () => {
{} as never,
{} as never,
{} as never,
+ {} as never,
);
return { service, threadRepository, messageRepository };
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/services/__tests__/workflow-agent-conversation.workspace-service.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/services/__tests__/workflow-agent-conversation.workspace-service.spec.ts
index e778edc2e5a..b54f89569bb 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/services/__tests__/workflow-agent-conversation.workspace-service.spec.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/services/__tests__/workflow-agent-conversation.workspace-service.spec.ts
@@ -57,6 +57,7 @@ const buildService = ({
} as never,
workflowRunWorkspaceService as never,
workflowRunRecordShareService as never,
+ {} as never,
);
return {
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/utils/__tests__/build-ai-agent-step-log.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/utils/__tests__/build-ai-agent-step-log.util.spec.ts
index aaa6a3ddf8c..4c26b4fe61d 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/utils/__tests__/build-ai-agent-step-log.util.spec.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/ai-agent/utils/__tests__/build-ai-agent-step-log.util.spec.ts
@@ -30,6 +30,14 @@ const baseExecutionResult: AgentExecutionResult = {
modelId: 'claude-sonnet-4',
totalCostInDollars: 0.012,
creditsUsedMicro: 12_000,
+ turnUsage: {
+ inputTokens: 100,
+ outputTokens: 50,
+ cacheReadTokens: 20,
+ cacheCreationTokens: 5,
+ inputCredits: 0,
+ outputCredits: 0,
+ },
steps: [],
};
diff --git a/packages/twenty-server/test/integration/graphql/suites/workflow/core-workflow-execution.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/workflow/core-workflow-execution.integration-spec.ts
index 5d43e92be5d..a47074380b2 100644
--- a/packages/twenty-server/test/integration/graphql/suites/workflow/core-workflow-execution.integration-spec.ts
+++ b/packages/twenty-server/test/integration/graphql/suites/workflow/core-workflow-execution.integration-spec.ts
@@ -13,6 +13,7 @@ import { WorkflowActionType } from 'twenty-shared/workflow';
import {
type WorkflowAction,
+ type WorkflowAiAgentAction,
type WorkflowEmptyAction,
} from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';
import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';
@@ -996,7 +997,7 @@ describe('core workflow execution and queue compatibility (e2e)', () => {
options: [{ label: 'Send it' }, { label: 'Hold it' }],
};
- const agentStep = (nextStepIds: string[]): WorkflowAction =>
+ const agentStep = (nextStepIds: string[]): WorkflowAiAgentAction =>
({
...emptyStep(),
name: 'Draft the quote',
@@ -1010,7 +1011,7 @@ describe('core workflow execution and queue compatibility (e2e)', () => {
workspaceMemberId: WORKSPACE_MEMBER_DATA_SEED_IDS.JANE,
},
},
- }) as WorkflowAction;
+ }) as WorkflowAiAgentAction;
const agentResult = (
overrides: Partial<AgentExecutionResult>,