diff --git a/apps/backend/src/lib/ai/ai-query-handlers.ts b/apps/backend/src/lib/ai/ai-query-handlers.ts index 821390069..3c2f301ff 100644 --- a/apps/backend/src/lib/ai/ai-query-handlers.ts +++ b/apps/backend/src/lib/ai/ai-query-handlers.ts @@ -167,10 +167,10 @@ function logMcpCallAndReview(args: { modelId: string, }): void { const { mcpCallMetadata, conversationId, correlationId, messages, contentBlocks, finalText, stepCount, startedAt, modelId } = args; - const firstUserMessage = messages.find(m => m.role === "user"); - const question = typeof firstUserMessage?.content === "string" - ? firstUserMessage.content - : JSON.stringify(firstUserMessage?.content ?? ""); + const lastUserMessage = messages.findLast(m => m.role === "user"); + const question = typeof lastUserMessage?.content === "string" + ? lastUserMessage.content + : JSON.stringify(lastUserMessage?.content ?? ""); const innerToolCallsJson = JSON.stringify(contentBlocks.filter(b => b.type === "tool-call")); const logPromise = logMcpCall({ diff --git a/apps/backend/src/lib/ai/mcp-logger.ts b/apps/backend/src/lib/ai/mcp-logger.ts index 316e2371c..fb01fea7c 100644 --- a/apps/backend/src/lib/ai/mcp-logger.ts +++ b/apps/backend/src/lib/ai/mcp-logger.ts @@ -60,12 +60,8 @@ async function rawCallReducer(token: string, reducer: string, args: unknown[]): "Authorization": `Bearer ${token}`, }, body: JSON.stringify(args, (_, v) => { - if (typeof v !== "bigint") return v; - // SpacetimeDB's HTTP API wants u64/i64 as JSON numbers, not strings. - // Convert bigints within JS safe-int range; fall back to string above that. - const MAX = BigInt(Number.MAX_SAFE_INTEGER); - if (v <= MAX && v >= -MAX) return Number(v); - return v.toString(); + if (typeof v === "bigint") return Number(v); + return v; }), }); if (!res.ok) { diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/add_manual_qa_reducer.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/add_manual_qa_reducer.ts deleted file mode 100644 index 97d707b5c..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/add_manual_qa_reducer.ts +++ /dev/null @@ -1,19 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - question: __t.string(), - answer: __t.string(), - publish: __t.bool(), - reviewedBy: __t.string(), -}; diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/add_operator_reducer.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/add_operator_reducer.ts deleted file mode 100644 index 11cc2cf43..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/add_operator_reducer.ts +++ /dev/null @@ -1,18 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - identity: __t.identity(), - stackUserId: __t.string(), - displayName: __t.string(), -}; diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/delete_qa_entry_reducer.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/delete_qa_entry_reducer.ts deleted file mode 100644 index 1fa706ca5..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/delete_qa_entry_reducer.ts +++ /dev/null @@ -1,16 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - correlationId: __t.string(), -}; diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/enroll_service_reducer.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/enroll_service_reducer.ts deleted file mode 100644 index ca2c40e7d..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/enroll_service_reducer.ts +++ /dev/null @@ -1,16 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - displayName: __t.string(), -}; diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/index.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/index.ts deleted file mode 100644 index c7b052d70..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/index.ts +++ /dev/null @@ -1,163 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -// This was generated using spacetimedb cli version 2.1.0 (commit 6981f48b4bc1a71c8dd9bdfe5a2c343f6370243d). - -/* eslint-disable */ -/* tslint:disable */ -import { - DbConnectionBuilder as __DbConnectionBuilder, - DbConnectionImpl as __DbConnectionImpl, - SubscriptionBuilderImpl as __SubscriptionBuilderImpl, - TypeBuilder as __TypeBuilder, - Uuid as __Uuid, - convertToAccessorMap as __convertToAccessorMap, - makeQueryBuilder as __makeQueryBuilder, - procedureSchema as __procedureSchema, - procedures as __procedures, - reducerSchema as __reducerSchema, - reducers as __reducers, - schema as __schema, - t as __t, - table as __table, - type AlgebraicTypeType as __AlgebraicTypeType, - type DbConnectionConfig as __DbConnectionConfig, - type ErrorContextInterface as __ErrorContextInterface, - type Event as __Event, - type EventContextInterface as __EventContextInterface, - type Infer as __Infer, - type QueryBuilder as __QueryBuilder, - type ReducerEventContextInterface as __ReducerEventContextInterface, - type RemoteModule as __RemoteModule, - type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, - type SubscriptionHandleImpl as __SubscriptionHandleImpl, -} from "spacetimedb"; - -// Import all reducer arg schemas -import AddManualQaReducer from "./add_manual_qa_reducer"; -import AddOperatorReducer from "./add_operator_reducer"; -import DeleteQaEntryReducer from "./delete_qa_entry_reducer"; -import EnrollServiceReducer from "./enroll_service_reducer"; -import LogAiQueryReducer from "./log_ai_query_reducer"; -import LogMcpCallReducer from "./log_mcp_call_reducer"; -import MarkHumanReviewedReducer from "./mark_human_reviewed_reducer"; -import RemoveOperatorReducer from "./remove_operator_reducer"; -import UnmarkHumanReviewedReducer from "./unmark_human_reviewed_reducer"; -import UpdateHumanCorrectionReducer from "./update_human_correction_reducer"; -import UpdateMcpQaReviewReducer from "./update_mcp_qa_review_reducer"; - -// Import all procedure arg schemas - -// Import all table schema definitions -import MyVisibleAiQueryLogRow from "./my_visible_ai_query_log_table"; -import MyVisibleMcpCallLogRow from "./my_visible_mcp_call_log_table"; -import OperatorsRow from "./operators_table"; -import PublishedQaRow from "./published_qa_table"; - -/** Type-only namespace exports for generated type groups. */ - -/** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ -const tablesSchema = __schema({ - operators: __table({ - name: 'operators', - indexes: [ - { accessor: 'identity', name: 'operators_identity_idx_btree', algorithm: 'btree', columns: [ - 'identity', - ] }, - ], - constraints: [ - { name: 'operators_identity_key', constraint: 'unique', columns: ['identity'] }, - ], - }, OperatorsRow), - myVisibleAiQueryLog: __table({ - name: 'my_visible_ai_query_log', - indexes: [ - ], - constraints: [ - ], - }, MyVisibleAiQueryLogRow), - myVisibleMcpCallLog: __table({ - name: 'my_visible_mcp_call_log', - indexes: [ - ], - constraints: [ - ], - }, MyVisibleMcpCallLogRow), - publishedQa: __table({ - name: 'published_qa', - indexes: [ - ], - constraints: [ - ], - }, PublishedQaRow), -}); - -/** The schema information for all reducers in this module. This is defined the same way as the reducers would have been defined in the server, except the body of the reducer is omitted in code generation. */ -const reducersSchema = __reducers( - __reducerSchema("add_manual_qa", AddManualQaReducer), - __reducerSchema("add_operator", AddOperatorReducer), - __reducerSchema("delete_qa_entry", DeleteQaEntryReducer), - __reducerSchema("enroll_service", EnrollServiceReducer), - __reducerSchema("log_ai_query", LogAiQueryReducer), - __reducerSchema("log_mcp_call", LogMcpCallReducer), - __reducerSchema("mark_human_reviewed", MarkHumanReviewedReducer), - __reducerSchema("remove_operator", RemoveOperatorReducer), - __reducerSchema("unmark_human_reviewed", UnmarkHumanReviewedReducer), - __reducerSchema("update_human_correction", UpdateHumanCorrectionReducer), - __reducerSchema("update_mcp_qa_review", UpdateMcpQaReviewReducer), -); - -/** The schema information for all procedures in this module. This is defined the same way as the procedures would have been defined in the server. */ -const proceduresSchema = __procedures( -); - -/** The remote SpacetimeDB module schema, both runtime and type information. */ -const REMOTE_MODULE = { - versionInfo: { - cliVersion: "2.1.0" as const, - }, - tables: tablesSchema.schemaType.tables, - reducers: reducersSchema.reducersType.reducers, - ...proceduresSchema, -} satisfies __RemoteModule< - typeof tablesSchema.schemaType, - typeof reducersSchema.reducersType, - typeof proceduresSchema ->; - -/** The tables available in this remote SpacetimeDB module. Each table reference doubles as a query builder. */ -export const tables: __QueryBuilder = __makeQueryBuilder(tablesSchema.schemaType); - -/** The reducers available in this remote SpacetimeDB module. */ -export const reducers = __convertToAccessorMap(reducersSchema.reducersType.reducers); - -/** The context type returned in callbacks for all possible events. */ -export type EventContext = __EventContextInterface; -/** The context type returned in callbacks for reducer events. */ -export type ReducerEventContext = __ReducerEventContextInterface; -/** The context type returned in callbacks for subscription events. */ -export type SubscriptionEventContext = __SubscriptionEventContextInterface; -/** The context type returned in callbacks for error events. */ -export type ErrorContext = __ErrorContextInterface; -/** The subscription handle type to manage active subscriptions created from a {@link SubscriptionBuilder}. */ -export type SubscriptionHandle = __SubscriptionHandleImpl; - -/** Builder class to configure a new subscription to the remote SpacetimeDB instance. */ -export class SubscriptionBuilder extends __SubscriptionBuilderImpl {} - -/** Builder class to configure a new database connection to the remote SpacetimeDB instance. */ -export class DbConnectionBuilder extends __DbConnectionBuilder {} - -/** The typed database connection to manage connections to the remote SpacetimeDB instance. This class has type information specific to the generated module. */ -export class DbConnection extends __DbConnectionImpl { - /** Creates a new {@link DbConnectionBuilder} to configure and connect to the remote SpacetimeDB instance. */ - static builder = (): DbConnectionBuilder => { - return new DbConnectionBuilder(REMOTE_MODULE, (config: __DbConnectionConfig) => new DbConnection(config)); - }; - - /** Creates a new {@link SubscriptionBuilder} to configure a subscription to the remote SpacetimeDB instance. */ - override subscriptionBuilder = (): SubscriptionBuilder => { - return new SubscriptionBuilder(this); - }; -} - diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/log_ai_query_reducer.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/log_ai_query_reducer.ts deleted file mode 100644 index 62f5a5fab..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/log_ai_query_reducer.ts +++ /dev/null @@ -1,37 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - correlationId: __t.string(), - mode: __t.string(), - systemPromptId: __t.string(), - quality: __t.string(), - speed: __t.string(), - modelId: __t.string(), - isAuthenticated: __t.bool(), - projectId: __t.option(__t.string()), - userId: __t.option(__t.string()), - requestedToolsJson: __t.string(), - messagesJson: __t.string(), - stepsJson: __t.string(), - finalText: __t.string(), - inputTokens: __t.option(__t.u32()), - outputTokens: __t.option(__t.u32()), - cachedInputTokens: __t.option(__t.u32()), - costUsd: __t.option(__t.f64()), - stepCount: __t.u32(), - durationMs: __t.u64(), - errorMessage: __t.option(__t.string()), - mcpCorrelationId: __t.option(__t.string()), - conversationId: __t.option(__t.string()), -}; diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/log_mcp_call_reducer.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/log_mcp_call_reducer.ts deleted file mode 100644 index 772cd1fc7..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/log_mcp_call_reducer.ts +++ /dev/null @@ -1,27 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - correlationId: __t.string(), - conversationId: __t.option(__t.string()), - toolName: __t.string(), - reason: __t.string(), - userPrompt: __t.string(), - question: __t.string(), - response: __t.string(), - stepCount: __t.u32(), - innerToolCallsJson: __t.string(), - durationMs: __t.u64(), - modelId: __t.string(), - errorMessage: __t.option(__t.string()), -}; diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/mark_human_reviewed_reducer.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/mark_human_reviewed_reducer.ts deleted file mode 100644 index 87a1e7d92..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/mark_human_reviewed_reducer.ts +++ /dev/null @@ -1,17 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - correlationId: __t.string(), - reviewedBy: __t.string(), -}; diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/my_visible_ai_query_log_table.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/my_visible_ai_query_log_table.ts deleted file mode 100644 index d1e34f127..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/my_visible_ai_query_log_table.ts +++ /dev/null @@ -1,39 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default __t.row({ - id: __t.u64(), - shard: __t.u8(), - correlationId: __t.string().name("correlation_id"), - createdAt: __t.timestamp().name("created_at"), - mode: __t.string(), - systemPromptId: __t.string().name("system_prompt_id"), - quality: __t.string(), - speed: __t.string(), - modelId: __t.string().name("model_id"), - isAuthenticated: __t.bool().name("is_authenticated"), - projectId: __t.option(__t.string()).name("project_id"), - userId: __t.option(__t.string()).name("user_id"), - requestedToolsJson: __t.string().name("requested_tools_json"), - messagesJson: __t.string().name("messages_json"), - stepsJson: __t.string().name("steps_json"), - finalText: __t.string().name("final_text"), - inputTokens: __t.option(__t.u32()).name("input_tokens"), - outputTokens: __t.option(__t.u32()).name("output_tokens"), - cachedInputTokens: __t.option(__t.u32()).name("cached_input_tokens"), - costUsd: __t.option(__t.f64()).name("cost_usd"), - stepCount: __t.u32().name("step_count"), - durationMs: __t.u64().name("duration_ms"), - errorMessage: __t.option(__t.string()).name("error_message"), - mcpCorrelationId: __t.option(__t.string()).name("mcp_correlation_id"), - conversationId: __t.option(__t.string()).name("conversation_id"), -}); diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/my_visible_mcp_call_log_table.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/my_visible_mcp_call_log_table.ts deleted file mode 100644 index cd54c54f7..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/my_visible_mcp_call_log_table.ts +++ /dev/null @@ -1,45 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default __t.row({ - id: __t.u64(), - shard: __t.u8(), - correlationId: __t.string().name("correlation_id"), - conversationId: __t.option(__t.string()).name("conversation_id"), - createdAt: __t.timestamp().name("created_at"), - toolName: __t.string().name("tool_name"), - reason: __t.string(), - userPrompt: __t.string().name("user_prompt"), - question: __t.string(), - response: __t.string(), - stepCount: __t.u32().name("step_count"), - innerToolCallsJson: __t.string().name("inner_tool_calls_json"), - durationMs: __t.u64().name("duration_ms"), - modelId: __t.string().name("model_id"), - errorMessage: __t.option(__t.string()).name("error_message"), - qaReviewedAt: __t.option(__t.timestamp()).name("qa_reviewed_at"), - qaNeedsHumanReview: __t.option(__t.bool()).name("qa_needs_human_review"), - qaAnswerCorrect: __t.option(__t.bool()).name("qa_answer_correct"), - qaAnswerRelevant: __t.option(__t.bool()).name("qa_answer_relevant"), - qaFlagsJson: __t.option(__t.string()).name("qa_flags_json"), - qaImprovementSuggestions: __t.option(__t.string()).name("qa_improvement_suggestions"), - qaOverallScore: __t.option(__t.u32()).name("qa_overall_score"), - qaReviewModelId: __t.option(__t.string()).name("qa_review_model_id"), - qaConversationJson: __t.option(__t.string()).name("qa_conversation_json"), - qaErrorMessage: __t.option(__t.string()).name("qa_error_message"), - humanReviewedAt: __t.option(__t.timestamp()).name("human_reviewed_at"), - humanReviewedBy: __t.option(__t.string()).name("human_reviewed_by"), - humanCorrectedQuestion: __t.option(__t.string()).name("human_corrected_question"), - humanCorrectedAnswer: __t.option(__t.string()).name("human_corrected_answer"), - publishedToQa: __t.bool().name("published_to_qa"), - publishedAt: __t.option(__t.timestamp()).name("published_at"), -}); diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/operators_table.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/operators_table.ts deleted file mode 100644 index 9f5a0d22f..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/operators_table.ts +++ /dev/null @@ -1,18 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default __t.row({ - identity: __t.identity().primaryKey(), - addedAt: __t.timestamp().name("added_at"), - stackUserId: __t.string().name("stack_user_id"), - displayName: __t.string().name("display_name"), -}); diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/published_qa_table.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/published_qa_table.ts deleted file mode 100644 index cd54c54f7..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/published_qa_table.ts +++ /dev/null @@ -1,45 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default __t.row({ - id: __t.u64(), - shard: __t.u8(), - correlationId: __t.string().name("correlation_id"), - conversationId: __t.option(__t.string()).name("conversation_id"), - createdAt: __t.timestamp().name("created_at"), - toolName: __t.string().name("tool_name"), - reason: __t.string(), - userPrompt: __t.string().name("user_prompt"), - question: __t.string(), - response: __t.string(), - stepCount: __t.u32().name("step_count"), - innerToolCallsJson: __t.string().name("inner_tool_calls_json"), - durationMs: __t.u64().name("duration_ms"), - modelId: __t.string().name("model_id"), - errorMessage: __t.option(__t.string()).name("error_message"), - qaReviewedAt: __t.option(__t.timestamp()).name("qa_reviewed_at"), - qaNeedsHumanReview: __t.option(__t.bool()).name("qa_needs_human_review"), - qaAnswerCorrect: __t.option(__t.bool()).name("qa_answer_correct"), - qaAnswerRelevant: __t.option(__t.bool()).name("qa_answer_relevant"), - qaFlagsJson: __t.option(__t.string()).name("qa_flags_json"), - qaImprovementSuggestions: __t.option(__t.string()).name("qa_improvement_suggestions"), - qaOverallScore: __t.option(__t.u32()).name("qa_overall_score"), - qaReviewModelId: __t.option(__t.string()).name("qa_review_model_id"), - qaConversationJson: __t.option(__t.string()).name("qa_conversation_json"), - qaErrorMessage: __t.option(__t.string()).name("qa_error_message"), - humanReviewedAt: __t.option(__t.timestamp()).name("human_reviewed_at"), - humanReviewedBy: __t.option(__t.string()).name("human_reviewed_by"), - humanCorrectedQuestion: __t.option(__t.string()).name("human_corrected_question"), - humanCorrectedAnswer: __t.option(__t.string()).name("human_corrected_answer"), - publishedToQa: __t.bool().name("published_to_qa"), - publishedAt: __t.option(__t.timestamp()).name("published_at"), -}); diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/remove_operator_reducer.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/remove_operator_reducer.ts deleted file mode 100644 index 0dfadd7bd..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/remove_operator_reducer.ts +++ /dev/null @@ -1,16 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - identity: __t.identity(), -}; diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/types.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/types.ts deleted file mode 100644 index b37d5ae23..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/types.ts +++ /dev/null @@ -1,93 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export const AiQueryLog = __t.object("AiQueryLog", { - id: __t.u64(), - shard: __t.u8(), - correlationId: __t.string(), - createdAt: __t.timestamp(), - mode: __t.string(), - systemPromptId: __t.string(), - quality: __t.string(), - speed: __t.string(), - modelId: __t.string(), - isAuthenticated: __t.bool(), - projectId: __t.option(__t.string()), - userId: __t.option(__t.string()), - requestedToolsJson: __t.string(), - messagesJson: __t.string(), - stepsJson: __t.string(), - finalText: __t.string(), - inputTokens: __t.option(__t.u32()), - outputTokens: __t.option(__t.u32()), - cachedInputTokens: __t.option(__t.u32()), - costUsd: __t.option(__t.f64()), - stepCount: __t.u32(), - durationMs: __t.u64(), - errorMessage: __t.option(__t.string()), - mcpCorrelationId: __t.option(__t.string()), - conversationId: __t.option(__t.string()), -}); -export type AiQueryLog = __Infer; - -export const McpCallLog = __t.object("McpCallLog", { - id: __t.u64(), - shard: __t.u8(), - correlationId: __t.string(), - conversationId: __t.option(__t.string()), - createdAt: __t.timestamp(), - toolName: __t.string(), - reason: __t.string(), - userPrompt: __t.string(), - question: __t.string(), - response: __t.string(), - stepCount: __t.u32(), - innerToolCallsJson: __t.string(), - durationMs: __t.u64(), - modelId: __t.string(), - errorMessage: __t.option(__t.string()), - qaReviewedAt: __t.option(__t.timestamp()), - qaNeedsHumanReview: __t.option(__t.bool()), - qaAnswerCorrect: __t.option(__t.bool()), - qaAnswerRelevant: __t.option(__t.bool()), - qaFlagsJson: __t.option(__t.string()), - qaImprovementSuggestions: __t.option(__t.string()), - qaOverallScore: __t.option(__t.u32()), - qaReviewModelId: __t.option(__t.string()), - qaConversationJson: __t.option(__t.string()), - qaErrorMessage: __t.option(__t.string()), - humanReviewedAt: __t.option(__t.timestamp()), - humanReviewedBy: __t.option(__t.string()), - humanCorrectedQuestion: __t.option(__t.string()), - humanCorrectedAnswer: __t.option(__t.string()), - publishedToQa: __t.bool(), - publishedAt: __t.option(__t.timestamp()), -}); -export type McpCallLog = __Infer; - -export const MyVisibleAiQueryLog = __t.object("MyVisibleAiQueryLog", {}); -export type MyVisibleAiQueryLog = __Infer; - -export const MyVisibleMcpCallLog = __t.object("MyVisibleMcpCallLog", {}); -export type MyVisibleMcpCallLog = __Infer; - -export const Operators = __t.object("Operators", { - identity: __t.identity(), - addedAt: __t.timestamp(), - stackUserId: __t.string(), - displayName: __t.string(), -}); -export type Operators = __Infer; - -export const PublishedQa = __t.object("PublishedQa", {}); -export type PublishedQa = __Infer; - diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/types/procedures.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/types/procedures.ts deleted file mode 100644 index d5ac825c9..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/types/procedures.ts +++ /dev/null @@ -1,10 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { type Infer as __Infer } from "spacetimedb"; - -// Import all procedure arg schemas - - diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/types/reducers.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/types/reducers.ts deleted file mode 100644 index c998a5041..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/types/reducers.ts +++ /dev/null @@ -1,32 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { type Infer as __Infer } from "spacetimedb"; - -// Import all reducer arg schemas -import AddManualQaReducer from "../add_manual_qa_reducer"; -import AddOperatorReducer from "../add_operator_reducer"; -import DeleteQaEntryReducer from "../delete_qa_entry_reducer"; -import EnrollServiceReducer from "../enroll_service_reducer"; -import LogAiQueryReducer from "../log_ai_query_reducer"; -import LogMcpCallReducer from "../log_mcp_call_reducer"; -import MarkHumanReviewedReducer from "../mark_human_reviewed_reducer"; -import RemoveOperatorReducer from "../remove_operator_reducer"; -import UnmarkHumanReviewedReducer from "../unmark_human_reviewed_reducer"; -import UpdateHumanCorrectionReducer from "../update_human_correction_reducer"; -import UpdateMcpQaReviewReducer from "../update_mcp_qa_review_reducer"; - -export type AddManualQaParams = __Infer; -export type AddOperatorParams = __Infer; -export type DeleteQaEntryParams = __Infer; -export type EnrollServiceParams = __Infer; -export type LogAiQueryParams = __Infer; -export type LogMcpCallParams = __Infer; -export type MarkHumanReviewedParams = __Infer; -export type RemoveOperatorParams = __Infer; -export type UnmarkHumanReviewedParams = __Infer; -export type UpdateHumanCorrectionParams = __Infer; -export type UpdateMcpQaReviewParams = __Infer; - diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/unmark_human_reviewed_reducer.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/unmark_human_reviewed_reducer.ts deleted file mode 100644 index 1fa706ca5..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/unmark_human_reviewed_reducer.ts +++ /dev/null @@ -1,16 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - correlationId: __t.string(), -}; diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/update_human_correction_reducer.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/update_human_correction_reducer.ts deleted file mode 100644 index 2ae110a19..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/update_human_correction_reducer.ts +++ /dev/null @@ -1,20 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - correlationId: __t.string(), - correctedQuestion: __t.string(), - correctedAnswer: __t.string(), - publish: __t.bool(), - reviewedBy: __t.string(), -}; diff --git a/apps/backend/src/lib/ai/spacetimedb-bindings/update_mcp_qa_review_reducer.ts b/apps/backend/src/lib/ai/spacetimedb-bindings/update_mcp_qa_review_reducer.ts deleted file mode 100644 index 035e1d017..000000000 --- a/apps/backend/src/lib/ai/spacetimedb-bindings/update_mcp_qa_review_reducer.ts +++ /dev/null @@ -1,25 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - correlationId: __t.string(), - qaNeedsHumanReview: __t.bool(), - qaAnswerCorrect: __t.bool(), - qaAnswerRelevant: __t.bool(), - qaFlagsJson: __t.string(), - qaImprovementSuggestions: __t.string(), - qaOverallScore: __t.u32(), - qaReviewModelId: __t.string(), - qaConversationJson: __t.option(__t.string()), - qaErrorMessage: __t.option(__t.string()), -}; diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/add_manual_qa_reducer.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/add_manual_qa_reducer.ts deleted file mode 100644 index 97d707b5c..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/add_manual_qa_reducer.ts +++ /dev/null @@ -1,19 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - question: __t.string(), - answer: __t.string(), - publish: __t.bool(), - reviewedBy: __t.string(), -}; diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/add_operator_reducer.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/add_operator_reducer.ts deleted file mode 100644 index 11cc2cf43..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/add_operator_reducer.ts +++ /dev/null @@ -1,18 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - identity: __t.identity(), - stackUserId: __t.string(), - displayName: __t.string(), -}; diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/delete_qa_entry_reducer.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/delete_qa_entry_reducer.ts deleted file mode 100644 index 1fa706ca5..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/delete_qa_entry_reducer.ts +++ /dev/null @@ -1,16 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - correlationId: __t.string(), -}; diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/enroll_service_reducer.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/enroll_service_reducer.ts deleted file mode 100644 index ca2c40e7d..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/enroll_service_reducer.ts +++ /dev/null @@ -1,16 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - displayName: __t.string(), -}; diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/index.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/index.ts deleted file mode 100644 index 4b7e18799..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/index.ts +++ /dev/null @@ -1,153 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -// This was generated using spacetimedb cli version 2.1.0 (commit 6981f48b4bc1a71c8dd9bdfe5a2c343f6370243d). - -/* eslint-disable */ -/* tslint:disable */ -import { - DbConnectionBuilder as __DbConnectionBuilder, - DbConnectionImpl as __DbConnectionImpl, - SubscriptionBuilderImpl as __SubscriptionBuilderImpl, - TypeBuilder as __TypeBuilder, - Uuid as __Uuid, - convertToAccessorMap as __convertToAccessorMap, - makeQueryBuilder as __makeQueryBuilder, - procedureSchema as __procedureSchema, - procedures as __procedures, - reducerSchema as __reducerSchema, - reducers as __reducers, - schema as __schema, - t as __t, - table as __table, - type AlgebraicTypeType as __AlgebraicTypeType, - type DbConnectionConfig as __DbConnectionConfig, - type ErrorContextInterface as __ErrorContextInterface, - type Event as __Event, - type EventContextInterface as __EventContextInterface, - type Infer as __Infer, - type QueryBuilder as __QueryBuilder, - type ReducerEventContextInterface as __ReducerEventContextInterface, - type RemoteModule as __RemoteModule, - type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, - type SubscriptionHandleImpl as __SubscriptionHandleImpl, -} from "spacetimedb"; - -// Import all reducer arg schemas -import AddManualQaReducer from "./add_manual_qa_reducer"; -import AddOperatorReducer from "./add_operator_reducer"; -import DeleteQaEntryReducer from "./delete_qa_entry_reducer"; -import EnrollServiceReducer from "./enroll_service_reducer"; -import LogAiQueryReducer from "./log_ai_query_reducer"; -import LogMcpCallReducer from "./log_mcp_call_reducer"; -import MarkHumanReviewedReducer from "./mark_human_reviewed_reducer"; -import RemoveOperatorReducer from "./remove_operator_reducer"; -import UpdateHumanCorrectionReducer from "./update_human_correction_reducer"; -import UpdateMcpQaReviewReducer from "./update_mcp_qa_review_reducer"; - -// Import all procedure arg schemas - -// Import all table schema definitions -import MyVisibleAiQueryLogRow from "./my_visible_ai_query_log_table"; -import MyVisibleMcpCallLogRow from "./my_visible_mcp_call_log_table"; -import OperatorsRow from "./operators_table"; - -/** Type-only namespace exports for generated type groups. */ - -/** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ -const tablesSchema = __schema({ - operators: __table({ - name: 'operators', - indexes: [ - { accessor: 'identity', name: 'operators_identity_idx_btree', algorithm: 'btree', columns: [ - 'identity', - ] }, - ], - constraints: [ - { name: 'operators_identity_key', constraint: 'unique', columns: ['identity'] }, - ], - }, OperatorsRow), - myVisibleAiQueryLog: __table({ - name: 'my_visible_ai_query_log', - indexes: [ - ], - constraints: [ - ], - }, MyVisibleAiQueryLogRow), - myVisibleMcpCallLog: __table({ - name: 'my_visible_mcp_call_log', - indexes: [ - ], - constraints: [ - ], - }, MyVisibleMcpCallLogRow), -}); - -/** The schema information for all reducers in this module. This is defined the same way as the reducers would have been defined in the server, except the body of the reducer is omitted in code generation. */ -const reducersSchema = __reducers( - __reducerSchema("add_manual_qa", AddManualQaReducer), - __reducerSchema("add_operator", AddOperatorReducer), - __reducerSchema("delete_qa_entry", DeleteQaEntryReducer), - __reducerSchema("enroll_service", EnrollServiceReducer), - __reducerSchema("log_ai_query", LogAiQueryReducer), - __reducerSchema("log_mcp_call", LogMcpCallReducer), - __reducerSchema("mark_human_reviewed", MarkHumanReviewedReducer), - __reducerSchema("remove_operator", RemoveOperatorReducer), - __reducerSchema("update_human_correction", UpdateHumanCorrectionReducer), - __reducerSchema("update_mcp_qa_review", UpdateMcpQaReviewReducer), -); - -/** The schema information for all procedures in this module. This is defined the same way as the procedures would have been defined in the server. */ -const proceduresSchema = __procedures( -); - -/** The remote SpacetimeDB module schema, both runtime and type information. */ -const REMOTE_MODULE = { - versionInfo: { - cliVersion: "2.1.0" as const, - }, - tables: tablesSchema.schemaType.tables, - reducers: reducersSchema.reducersType.reducers, - ...proceduresSchema, -} satisfies __RemoteModule< - typeof tablesSchema.schemaType, - typeof reducersSchema.reducersType, - typeof proceduresSchema ->; - -/** The tables available in this remote SpacetimeDB module. Each table reference doubles as a query builder. */ -export const tables: __QueryBuilder = __makeQueryBuilder(tablesSchema.schemaType); - -/** The reducers available in this remote SpacetimeDB module. */ -export const reducers = __convertToAccessorMap(reducersSchema.reducersType.reducers); - -/** The context type returned in callbacks for all possible events. */ -export type EventContext = __EventContextInterface; -/** The context type returned in callbacks for reducer events. */ -export type ReducerEventContext = __ReducerEventContextInterface; -/** The context type returned in callbacks for subscription events. */ -export type SubscriptionEventContext = __SubscriptionEventContextInterface; -/** The context type returned in callbacks for error events. */ -export type ErrorContext = __ErrorContextInterface; -/** The subscription handle type to manage active subscriptions created from a {@link SubscriptionBuilder}. */ -export type SubscriptionHandle = __SubscriptionHandleImpl; - -/** Builder class to configure a new subscription to the remote SpacetimeDB instance. */ -export class SubscriptionBuilder extends __SubscriptionBuilderImpl {} - -/** Builder class to configure a new database connection to the remote SpacetimeDB instance. */ -export class DbConnectionBuilder extends __DbConnectionBuilder {} - -/** The typed database connection to manage connections to the remote SpacetimeDB instance. This class has type information specific to the generated module. */ -export class DbConnection extends __DbConnectionImpl { - /** Creates a new {@link DbConnectionBuilder} to configure and connect to the remote SpacetimeDB instance. */ - static builder = (): DbConnectionBuilder => { - return new DbConnectionBuilder(REMOTE_MODULE, (config: __DbConnectionConfig) => new DbConnection(config)); - }; - - /** Creates a new {@link SubscriptionBuilder} to configure a subscription to the remote SpacetimeDB instance. */ - override subscriptionBuilder = (): SubscriptionBuilder => { - return new SubscriptionBuilder(this); - }; -} - diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/log_ai_query_reducer.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/log_ai_query_reducer.ts deleted file mode 100644 index 62f5a5fab..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/log_ai_query_reducer.ts +++ /dev/null @@ -1,37 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - correlationId: __t.string(), - mode: __t.string(), - systemPromptId: __t.string(), - quality: __t.string(), - speed: __t.string(), - modelId: __t.string(), - isAuthenticated: __t.bool(), - projectId: __t.option(__t.string()), - userId: __t.option(__t.string()), - requestedToolsJson: __t.string(), - messagesJson: __t.string(), - stepsJson: __t.string(), - finalText: __t.string(), - inputTokens: __t.option(__t.u32()), - outputTokens: __t.option(__t.u32()), - cachedInputTokens: __t.option(__t.u32()), - costUsd: __t.option(__t.f64()), - stepCount: __t.u32(), - durationMs: __t.u64(), - errorMessage: __t.option(__t.string()), - mcpCorrelationId: __t.option(__t.string()), - conversationId: __t.option(__t.string()), -}; diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/log_mcp_call_reducer.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/log_mcp_call_reducer.ts deleted file mode 100644 index 772cd1fc7..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/log_mcp_call_reducer.ts +++ /dev/null @@ -1,27 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - correlationId: __t.string(), - conversationId: __t.option(__t.string()), - toolName: __t.string(), - reason: __t.string(), - userPrompt: __t.string(), - question: __t.string(), - response: __t.string(), - stepCount: __t.u32(), - innerToolCallsJson: __t.string(), - durationMs: __t.u64(), - modelId: __t.string(), - errorMessage: __t.option(__t.string()), -}; diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/mark_human_reviewed_reducer.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/mark_human_reviewed_reducer.ts deleted file mode 100644 index 87a1e7d92..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/mark_human_reviewed_reducer.ts +++ /dev/null @@ -1,17 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - correlationId: __t.string(), - reviewedBy: __t.string(), -}; diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/my_visible_ai_query_log_table.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/my_visible_ai_query_log_table.ts deleted file mode 100644 index 8be77beea..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/my_visible_ai_query_log_table.ts +++ /dev/null @@ -1,38 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default __t.row({ - id: __t.u64(), - correlationId: __t.string().name("correlation_id"), - createdAt: __t.timestamp().name("created_at"), - mode: __t.string(), - systemPromptId: __t.string().name("system_prompt_id"), - quality: __t.string(), - speed: __t.string(), - modelId: __t.string().name("model_id"), - isAuthenticated: __t.bool().name("is_authenticated"), - projectId: __t.option(__t.string()).name("project_id"), - userId: __t.option(__t.string()).name("user_id"), - requestedToolsJson: __t.string().name("requested_tools_json"), - messagesJson: __t.string().name("messages_json"), - stepsJson: __t.string().name("steps_json"), - finalText: __t.string().name("final_text"), - inputTokens: __t.option(__t.u32()).name("input_tokens"), - outputTokens: __t.option(__t.u32()).name("output_tokens"), - cachedInputTokens: __t.option(__t.u32()).name("cached_input_tokens"), - costUsd: __t.option(__t.f64()).name("cost_usd"), - stepCount: __t.u32().name("step_count"), - durationMs: __t.u64().name("duration_ms"), - errorMessage: __t.option(__t.string()).name("error_message"), - mcpCorrelationId: __t.option(__t.string()).name("mcp_correlation_id"), - conversationId: __t.option(__t.string()).name("conversation_id"), -}); diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/my_visible_mcp_call_log_table.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/my_visible_mcp_call_log_table.ts deleted file mode 100644 index efcbf7542..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/my_visible_mcp_call_log_table.ts +++ /dev/null @@ -1,44 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default __t.row({ - id: __t.u64(), - correlationId: __t.string().name("correlation_id"), - conversationId: __t.option(__t.string()).name("conversation_id"), - createdAt: __t.timestamp().name("created_at"), - toolName: __t.string().name("tool_name"), - reason: __t.string(), - userPrompt: __t.string().name("user_prompt"), - question: __t.string(), - response: __t.string(), - stepCount: __t.u32().name("step_count"), - innerToolCallsJson: __t.string().name("inner_tool_calls_json"), - durationMs: __t.u64().name("duration_ms"), - modelId: __t.string().name("model_id"), - errorMessage: __t.option(__t.string()).name("error_message"), - qaReviewedAt: __t.option(__t.timestamp()).name("qa_reviewed_at"), - qaNeedsHumanReview: __t.option(__t.bool()).name("qa_needs_human_review"), - qaAnswerCorrect: __t.option(__t.bool()).name("qa_answer_correct"), - qaAnswerRelevant: __t.option(__t.bool()).name("qa_answer_relevant"), - qaFlagsJson: __t.option(__t.string()).name("qa_flags_json"), - qaImprovementSuggestions: __t.option(__t.string()).name("qa_improvement_suggestions"), - qaOverallScore: __t.option(__t.u32()).name("qa_overall_score"), - qaReviewModelId: __t.option(__t.string()).name("qa_review_model_id"), - qaConversationJson: __t.option(__t.string()).name("qa_conversation_json"), - qaErrorMessage: __t.option(__t.string()).name("qa_error_message"), - humanReviewedAt: __t.option(__t.timestamp()).name("human_reviewed_at"), - humanReviewedBy: __t.option(__t.string()).name("human_reviewed_by"), - humanCorrectedQuestion: __t.option(__t.string()).name("human_corrected_question"), - humanCorrectedAnswer: __t.option(__t.string()).name("human_corrected_answer"), - publishedToQa: __t.option(__t.bool()).name("published_to_qa"), - publishedAt: __t.option(__t.timestamp()).name("published_at"), -}); diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/operators_table.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/operators_table.ts deleted file mode 100644 index 9f5a0d22f..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/operators_table.ts +++ /dev/null @@ -1,18 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default __t.row({ - identity: __t.identity().primaryKey(), - addedAt: __t.timestamp().name("added_at"), - stackUserId: __t.string().name("stack_user_id"), - displayName: __t.string().name("display_name"), -}); diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/remove_operator_reducer.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/remove_operator_reducer.ts deleted file mode 100644 index 0dfadd7bd..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/remove_operator_reducer.ts +++ /dev/null @@ -1,16 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - identity: __t.identity(), -}; diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/types.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/types.ts deleted file mode 100644 index 44a480a64..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/types.ts +++ /dev/null @@ -1,88 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export const AiQueryLog = __t.object("AiQueryLog", { - id: __t.u64(), - correlationId: __t.string(), - createdAt: __t.timestamp(), - mode: __t.string(), - systemPromptId: __t.string(), - quality: __t.string(), - speed: __t.string(), - modelId: __t.string(), - isAuthenticated: __t.bool(), - projectId: __t.option(__t.string()), - userId: __t.option(__t.string()), - requestedToolsJson: __t.string(), - messagesJson: __t.string(), - stepsJson: __t.string(), - finalText: __t.string(), - inputTokens: __t.option(__t.u32()), - outputTokens: __t.option(__t.u32()), - cachedInputTokens: __t.option(__t.u32()), - costUsd: __t.option(__t.f64()), - stepCount: __t.u32(), - durationMs: __t.u64(), - errorMessage: __t.option(__t.string()), - mcpCorrelationId: __t.option(__t.string()), - conversationId: __t.option(__t.string()), -}); -export type AiQueryLog = __Infer; - -export const McpCallLog = __t.object("McpCallLog", { - id: __t.u64(), - correlationId: __t.string(), - conversationId: __t.option(__t.string()), - createdAt: __t.timestamp(), - toolName: __t.string(), - reason: __t.string(), - userPrompt: __t.string(), - question: __t.string(), - response: __t.string(), - stepCount: __t.u32(), - innerToolCallsJson: __t.string(), - durationMs: __t.u64(), - modelId: __t.string(), - errorMessage: __t.option(__t.string()), - qaReviewedAt: __t.option(__t.timestamp()), - qaNeedsHumanReview: __t.option(__t.bool()), - qaAnswerCorrect: __t.option(__t.bool()), - qaAnswerRelevant: __t.option(__t.bool()), - qaFlagsJson: __t.option(__t.string()), - qaImprovementSuggestions: __t.option(__t.string()), - qaOverallScore: __t.option(__t.u32()), - qaReviewModelId: __t.option(__t.string()), - qaConversationJson: __t.option(__t.string()), - qaErrorMessage: __t.option(__t.string()), - humanReviewedAt: __t.option(__t.timestamp()), - humanReviewedBy: __t.option(__t.string()), - humanCorrectedQuestion: __t.option(__t.string()), - humanCorrectedAnswer: __t.option(__t.string()), - publishedToQa: __t.option(__t.bool()), - publishedAt: __t.option(__t.timestamp()), -}); -export type McpCallLog = __Infer; - -export const MyVisibleAiQueryLog = __t.object("MyVisibleAiQueryLog", {}); -export type MyVisibleAiQueryLog = __Infer; - -export const MyVisibleMcpCallLog = __t.object("MyVisibleMcpCallLog", {}); -export type MyVisibleMcpCallLog = __Infer; - -export const Operators = __t.object("Operators", { - identity: __t.identity(), - addedAt: __t.timestamp(), - stackUserId: __t.string(), - displayName: __t.string(), -}); -export type Operators = __Infer; - diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/types/procedures.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/types/procedures.ts deleted file mode 100644 index d5ac825c9..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/types/procedures.ts +++ /dev/null @@ -1,10 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { type Infer as __Infer } from "spacetimedb"; - -// Import all procedure arg schemas - - diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/types/reducers.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/types/reducers.ts deleted file mode 100644 index 43dc2cecb..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/types/reducers.ts +++ /dev/null @@ -1,30 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { type Infer as __Infer } from "spacetimedb"; - -// Import all reducer arg schemas -import AddManualQaReducer from "../add_manual_qa_reducer"; -import AddOperatorReducer from "../add_operator_reducer"; -import DeleteQaEntryReducer from "../delete_qa_entry_reducer"; -import EnrollServiceReducer from "../enroll_service_reducer"; -import LogAiQueryReducer from "../log_ai_query_reducer"; -import LogMcpCallReducer from "../log_mcp_call_reducer"; -import MarkHumanReviewedReducer from "../mark_human_reviewed_reducer"; -import RemoveOperatorReducer from "../remove_operator_reducer"; -import UpdateHumanCorrectionReducer from "../update_human_correction_reducer"; -import UpdateMcpQaReviewReducer from "../update_mcp_qa_review_reducer"; - -export type AddManualQaParams = __Infer; -export type AddOperatorParams = __Infer; -export type DeleteQaEntryParams = __Infer; -export type EnrollServiceParams = __Infer; -export type LogAiQueryParams = __Infer; -export type LogMcpCallParams = __Infer; -export type MarkHumanReviewedParams = __Infer; -export type RemoveOperatorParams = __Infer; -export type UpdateHumanCorrectionParams = __Infer; -export type UpdateMcpQaReviewParams = __Infer; - diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/update_human_correction_reducer.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/update_human_correction_reducer.ts deleted file mode 100644 index 2ae110a19..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/update_human_correction_reducer.ts +++ /dev/null @@ -1,20 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - correlationId: __t.string(), - correctedQuestion: __t.string(), - correctedAnswer: __t.string(), - publish: __t.bool(), - reviewedBy: __t.string(), -}; diff --git a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/update_mcp_qa_review_reducer.ts b/apps/internal-tool/src/lib/ai/spacetimedb-bindings/update_mcp_qa_review_reducer.ts deleted file mode 100644 index 035e1d017..000000000 --- a/apps/internal-tool/src/lib/ai/spacetimedb-bindings/update_mcp_qa_review_reducer.ts +++ /dev/null @@ -1,25 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, -} from "spacetimedb"; - -export default { - token: __t.string(), - correlationId: __t.string(), - qaNeedsHumanReview: __t.bool(), - qaAnswerCorrect: __t.bool(), - qaAnswerRelevant: __t.bool(), - qaFlagsJson: __t.string(), - qaImprovementSuggestions: __t.string(), - qaOverallScore: __t.u32(), - qaReviewModelId: __t.string(), - qaConversationJson: __t.option(__t.string()), - qaErrorMessage: __t.option(__t.string()), -};