mirror of https://github.com/buster-so/buster.git
a little reorg
This commit is contained in:
parent
dada5cb0eb
commit
ff8530a08f
|
@ -1,9 +1,9 @@
|
|||
import type { ChatMessageResponseMessage } from '@buster/server-shared/chats';
|
||||
import type { ModelMessage } from 'ai';
|
||||
import type { CreateDashboardsOutput } from '../../../visualization-tools/create-dashboards-tool/create-dashboards-tool';
|
||||
import type { CreateMetricsOutput } from '../../../visualization-tools/create-metrics-tool/create-metrics-tool';
|
||||
import type { ModifyDashboardsOutput } from '../../../visualization-tools/modify-dashboards-tool/modify-dashboards-tool';
|
||||
import type { ModifyMetricsOutput } from '../../../visualization-tools/modify-metrics-tool/modify-metrics-tool';
|
||||
import type { CreateDashboardsOutput } from '../../../visualization-tools/dashboards/create-dashboards-tool/create-dashboards-tool';
|
||||
import type { ModifyDashboardsOutput } from '../../../visualization-tools/dashboards/modify-dashboards-tool/modify-dashboards-tool';
|
||||
import type { CreateMetricsOutput } from '../../../visualization-tools/metrics/create-metrics-tool/create-metrics-tool';
|
||||
import type { ModifyMetricsOutput } from '../../../visualization-tools/metrics/modify-metrics-tool/modify-metrics-tool';
|
||||
|
||||
// File tracking type similar to ExtractedFile from file-selection.ts
|
||||
interface ExtractedFile {
|
||||
|
|
|
@ -3,10 +3,10 @@ export { createIdleTool } from './communication-tools/idle-tool/idle-tool';
|
|||
export { createSubmitThoughtsTool } from './communication-tools/submit-thoughts-tool/submit-thoughts-tool';
|
||||
export { createSequentialThinkingTool } from './planning-thinking-tools/sequential-thinking-tool/sequential-thinking-tool';
|
||||
// Visualization tools - factory functions
|
||||
export { createCreateMetricsTool } from './visualization-tools/create-metrics-tool/create-metrics-tool';
|
||||
export { createModifyMetricsTool } from './visualization-tools/modify-metrics-tool/modify-metrics-tool';
|
||||
export { createCreateDashboardsTool } from './visualization-tools/create-dashboards-tool/create-dashboards-tool';
|
||||
export { createModifyDashboardsTool } from './visualization-tools/modify-dashboards-tool/modify-dashboards-tool';
|
||||
export { createCreateMetricsTool } from './visualization-tools/metrics/create-metrics-tool/create-metrics-tool';
|
||||
export { createModifyMetricsTool } from './visualization-tools/metrics/modify-metrics-tool/modify-metrics-tool';
|
||||
export { createCreateDashboardsTool } from './visualization-tools/dashboards/create-dashboards-tool/create-dashboards-tool';
|
||||
export { createModifyDashboardsTool } from './visualization-tools/dashboards/modify-dashboards-tool/modify-dashboards-tool';
|
||||
export { executeSql, createExecuteSqlTool } from './database-tools/execute-sql/execute-sql';
|
||||
export { executeSqlDocsAgent } from './database-tools/super-execute-sql/super-execute-sql';
|
||||
// File tools - factory functions
|
||||
|
|
|
@ -30,7 +30,7 @@ describe('createCreateDashboardsDelta', () => {
|
|||
const database = await import('@buster/database');
|
||||
updateMessageEntriesSpy = vi.mocked(database.updateMessageEntries);
|
||||
|
||||
const streaming = await import('../../../utils/streaming/optimistic-json-parser');
|
||||
const streaming = await import('../../../../utils/streaming/optimistic-json-parser');
|
||||
OptimisticJsonParser = streaming.OptimisticJsonParser as unknown as {
|
||||
parse: ReturnType<typeof vi.fn>;
|
||||
};
|
|
@ -4,7 +4,7 @@ import type { ToolCallOptions } from 'ai';
|
|||
import {
|
||||
OptimisticJsonParser,
|
||||
getOptimisticValue,
|
||||
} from '../../../utils/streaming/optimistic-json-parser';
|
||||
} from '../../../../utils/streaming/optimistic-json-parser';
|
||||
import type {
|
||||
CreateDashboardsContext,
|
||||
CreateDashboardsFile,
|
|
@ -11,7 +11,7 @@ import { wrapTraced } from 'braintrust';
|
|||
import { inArray } from 'drizzle-orm';
|
||||
import * as yaml from 'yaml';
|
||||
import { z } from 'zod';
|
||||
import { trackFileAssociations } from '../file-tracking-helper';
|
||||
import { trackFileAssociations } from '../../file-tracking-helper';
|
||||
import { createInitialDashboardVersionHistory } from '../version-history-helpers';
|
||||
import type { DashboardYml } from '../version-history-types';
|
||||
import type {
|
|
@ -1,7 +1,7 @@
|
|||
import { updateMessageEntries } from '@buster/database';
|
||||
import type { ChatMessageReasoningMessage } from '@buster/server-shared/chats';
|
||||
import type { ToolCallOptions } from 'ai';
|
||||
import type { DoneToolInput } from '../../communication-tools/done-tool/done-tool';
|
||||
import type { DoneToolInput } from '../../../communication-tools/done-tool/done-tool';
|
||||
import type {
|
||||
CreateDashboardsContext,
|
||||
CreateDashboardsInput,
|
|
@ -4,7 +4,7 @@ import { createCreateDashboardsDelta } from './create-dashboards-delta';
|
|||
import { createCreateDashboardsExecute } from './create-dashboards-execute';
|
||||
import { createCreateDashboardsFinish } from './create-dashboards-finish';
|
||||
import { createCreateDashboardsStart } from './create-dashboards-start';
|
||||
import { getDashboardToolDescription } from './get-dashboard-tool-descripton';
|
||||
import { getDashboardToolDescription } from '../helpers/get-dashboard-tool-descripton';
|
||||
|
||||
// Input schema for the create dashboards tool
|
||||
const CreateDashboardsInputSchema = z.object({
|
|
@ -4,7 +4,7 @@ import { wrapTraced } from 'braintrust';
|
|||
import {
|
||||
OptimisticJsonParser,
|
||||
getOptimisticValue,
|
||||
} from '../../../utils/streaming/optimistic-json-parser';
|
||||
} from '../../../../utils/streaming/optimistic-json-parser';
|
||||
import {
|
||||
TOOL_KEYS,
|
||||
createDashboardsReasoningMessage,
|
|
@ -6,7 +6,7 @@ import { wrapTraced } from 'braintrust';
|
|||
import { and, eq, inArray, isNull } from 'drizzle-orm';
|
||||
import * as yaml from 'yaml';
|
||||
import { z } from 'zod';
|
||||
import { trackFileAssociations } from '../file-tracking-helper';
|
||||
import { trackFileAssociations } from '../../file-tracking-helper';
|
||||
import { addDashboardVersionToHistory, getLatestVersionNumber } from '../version-history-helpers';
|
||||
import type { DashboardYml, VersionHistory } from '../version-history-types';
|
||||
import {
|
|
@ -3,7 +3,7 @@ import type { ChatMessageReasoningMessage } from '@buster/server-shared/chats';
|
|||
import {
|
||||
OptimisticJsonParser,
|
||||
getOptimisticValue,
|
||||
} from '../../../utils/streaming/optimistic-json-parser';
|
||||
} from '../../../../utils/streaming/optimistic-json-parser';
|
||||
import type {
|
||||
CreateMetricsContext,
|
||||
CreateMetricsInput,
|
|
@ -7,12 +7,12 @@ import { wrapTraced } from 'braintrust';
|
|||
import { inArray } from 'drizzle-orm';
|
||||
import * as yaml from 'yaml';
|
||||
import { z } from 'zod';
|
||||
import { getDataSource } from '../../../utils/get-data-source';
|
||||
import { getDataSource } from '../../../../utils/get-data-source';
|
||||
import {
|
||||
createPermissionErrorMessage,
|
||||
validateSqlPermissions,
|
||||
} from '../../../utils/sql-permissions';
|
||||
import { trackFileAssociations } from '../file-tracking-helper';
|
||||
} from '../../../../utils/sql-permissions';
|
||||
import { trackFileAssociations } from '../../file-tracking-helper';
|
||||
import { validateAndAdjustBarLineAxes } from '../helpers/bar-line-axis-validator';
|
||||
import { ensureTimeFrameQuoted } from '../helpers/time-frame-helper';
|
||||
import type {
|
|
@ -4,7 +4,7 @@ import { createCreateMetricsDelta } from './create-metrics-delta';
|
|||
import { createCreateMetricsExecute } from './create-metrics-execute';
|
||||
import { createCreateMetricsFinish } from './create-metrics-finish';
|
||||
import { createCreateMetricsStart } from './create-metrics-start';
|
||||
import { getMetricToolDescription } from './get-metric-tool-description';
|
||||
import { getMetricToolDescription } from '../helpers/get-metric-tool-description';
|
||||
|
||||
const CreateMetricsInputSchema = z.object({
|
||||
files: z
|
|
@ -46,7 +46,7 @@ describe('createModifyMetricsDelta', () => {
|
|||
describe('string delta handling', () => {
|
||||
it('should accumulate string deltas in argsText', async () => {
|
||||
const { OptimisticJsonParser, getOptimisticValue } = await import(
|
||||
'../../../utils/streaming/optimistic-json-parser'
|
||||
'../../../../utils/streaming/optimistic-json-parser'
|
||||
);
|
||||
(OptimisticJsonParser.parse as any).mockReturnValue({
|
||||
parsed: null,
|
||||
|
@ -64,7 +64,7 @@ describe('createModifyMetricsDelta', () => {
|
|||
|
||||
it('should update parsedArgs when JSON is parsed', async () => {
|
||||
const { OptimisticJsonParser, getOptimisticValue } = await import(
|
||||
'../../../utils/streaming/optimistic-json-parser'
|
||||
'../../../../utils/streaming/optimistic-json-parser'
|
||||
);
|
||||
const parsedData = { files: [{ id: 'metric-1', yml_content: 'content' }] };
|
||||
(OptimisticJsonParser.parse as any).mockReturnValue({
|
||||
|
@ -82,7 +82,7 @@ describe('createModifyMetricsDelta', () => {
|
|||
|
||||
it('should update state files from parsed array', async () => {
|
||||
const { OptimisticJsonParser, getOptimisticValue } = await import(
|
||||
'../../../utils/streaming/optimistic-json-parser'
|
||||
'../../../../utils/streaming/optimistic-json-parser'
|
||||
);
|
||||
(OptimisticJsonParser.parse as any).mockReturnValue({
|
||||
parsed: {},
|
||||
|
@ -114,7 +114,7 @@ describe('createModifyMetricsDelta', () => {
|
|||
|
||||
it('should update existing files in state', async () => {
|
||||
const { OptimisticJsonParser, getOptimisticValue } = await import(
|
||||
'../../../utils/streaming/optimistic-json-parser'
|
||||
'../../../../utils/streaming/optimistic-json-parser'
|
||||
);
|
||||
|
||||
// Pre-populate state with a file
|
||||
|
@ -142,7 +142,7 @@ describe('createModifyMetricsDelta', () => {
|
|||
|
||||
it('should handle partial file data', async () => {
|
||||
const { OptimisticJsonParser, getOptimisticValue } = await import(
|
||||
'../../../utils/streaming/optimistic-json-parser'
|
||||
'../../../../utils/streaming/optimistic-json-parser'
|
||||
);
|
||||
(OptimisticJsonParser.parse as any).mockReturnValue({
|
||||
parsed: {},
|
||||
|
@ -166,7 +166,7 @@ describe('createModifyMetricsDelta', () => {
|
|||
|
||||
it('should update database when messageId and reasoningEntryId exist', async () => {
|
||||
const { OptimisticJsonParser, getOptimisticValue } = await import(
|
||||
'../../../utils/streaming/optimistic-json-parser'
|
||||
'../../../../utils/streaming/optimistic-json-parser'
|
||||
);
|
||||
(OptimisticJsonParser.parse as any).mockReturnValue({
|
||||
parsed: {},
|
||||
|
@ -191,7 +191,7 @@ describe('createModifyMetricsDelta', () => {
|
|||
|
||||
it('should not update database when messageId is missing', async () => {
|
||||
const { OptimisticJsonParser, getOptimisticValue } = await import(
|
||||
'../../../utils/streaming/optimistic-json-parser'
|
||||
'../../../../utils/streaming/optimistic-json-parser'
|
||||
);
|
||||
context.messageId = undefined;
|
||||
|
||||
|
@ -210,7 +210,7 @@ describe('createModifyMetricsDelta', () => {
|
|||
|
||||
it('should not update database when reasoningEntryId is missing', async () => {
|
||||
const { OptimisticJsonParser, getOptimisticValue } = await import(
|
||||
'../../../utils/streaming/optimistic-json-parser'
|
||||
'../../../../utils/streaming/optimistic-json-parser'
|
||||
);
|
||||
state.reasoningEntryId = undefined;
|
||||
|
||||
|
@ -229,7 +229,7 @@ describe('createModifyMetricsDelta', () => {
|
|||
|
||||
it('should filter undefined entries before creating reasoning message', async () => {
|
||||
const { OptimisticJsonParser, getOptimisticValue } = await import(
|
||||
'../../../utils/streaming/optimistic-json-parser'
|
||||
'../../../../utils/streaming/optimistic-json-parser'
|
||||
);
|
||||
|
||||
// State with undefined entries
|
||||
|
@ -262,7 +262,7 @@ describe('createModifyMetricsDelta', () => {
|
|||
|
||||
it('should handle database update errors gracefully', async () => {
|
||||
const { OptimisticJsonParser, getOptimisticValue } = await import(
|
||||
'../../../utils/streaming/optimistic-json-parser'
|
||||
'../../../../utils/streaming/optimistic-json-parser'
|
||||
);
|
||||
(updateMessageFields as any).mockRejectedValue(new Error('Database error'));
|
||||
|
||||
|
@ -319,7 +319,7 @@ describe('createModifyMetricsDelta', () => {
|
|||
it('should log correct information', async () => {
|
||||
const consoleSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
|
||||
const { OptimisticJsonParser, getOptimisticValue } = await import(
|
||||
'../../../utils/streaming/optimistic-json-parser'
|
||||
'../../../../utils/streaming/optimistic-json-parser'
|
||||
);
|
||||
|
||||
(OptimisticJsonParser.parse as any).mockReturnValue({
|
|
@ -2,7 +2,7 @@ import { updateMessageFields } from '@buster/database';
|
|||
import {
|
||||
OptimisticJsonParser,
|
||||
getOptimisticValue,
|
||||
} from '../../../utils/streaming/optimistic-json-parser';
|
||||
} from '../../../../utils/streaming/optimistic-json-parser';
|
||||
import {
|
||||
MODIFY_METRICS_KEYS,
|
||||
createModifyMetricsReasoningMessage,
|
|
@ -4,12 +4,12 @@ import { wrapTraced } from 'braintrust';
|
|||
import { eq, inArray } from 'drizzle-orm';
|
||||
import * as yaml from 'yaml';
|
||||
import { z } from 'zod';
|
||||
import { getDataSource } from '../../../utils/get-data-source';
|
||||
import { getDataSource } from '../../../../utils/get-data-source';
|
||||
import {
|
||||
createPermissionErrorMessage,
|
||||
validateSqlPermissions,
|
||||
} from '../../../utils/sql-permissions';
|
||||
import { trackFileAssociations } from '../file-tracking-helper';
|
||||
} from '../../../../utils/sql-permissions';
|
||||
import { trackFileAssociations } from '../../file-tracking-helper';
|
||||
import { validateAndAdjustBarLineAxes } from '../helpers/bar-line-axis-validator';
|
||||
import { ensureTimeFrameQuoted } from '../helpers/time-frame-helper';
|
||||
import {
|
Loading…
Reference in New Issue