Files
TREK/server/src/db/entities/AssistantToolCalls.entity.ts
T
Maurice d24db65cb8 fix(assistant): green CI round, trip notes the assistant can keep, calmer change cards
- the assistant keeps facts for a trip (remember_for_trip) as a change card,
  applied into the user's trip notes; existing expenses can be changed
- change card fields as a few icon chips with the rest folded under Details,
  the day band marks only what changes, the week grid as compact tiles
- no map button on receipts of things that have no place on the map
- tests follow the composer's accessible name, the receipt's status icon and
  the GL map's container; the hanging stream helper honours an early abort
- Postgres probe: qualified columns in the upsert updates; entities restored
  to the generator's output; strict ratchet reads the SDK client as untyped
2026-10-22 21:30:26 +00:00

46 lines
1.7 KiB
TypeScript

import { EntityRepositoryType, type Opt, type Ref, defineEntity, p } from '@mikro-orm/core';
import { AssistantToolCallsRepository } from '../repositories/AssistantToolCalls.repository';
import { DbTimestampType } from '../types';
import { AssistantMessages } from './AssistantMessages.entity';
import { AssistantThreads } from './AssistantThreads.entity';
export class AssistantToolCalls {
[EntityRepositoryType]?: AssistantToolCallsRepository;
id!: string;
thread!: Ref<AssistantThreads>;
thread_id!: number;
message!: Ref<AssistantMessages>;
message_id!: number;
provider_call_id!: string;
tool_name!: string;
args!: string;
preview!: string;
state: string & Opt = 'approval_requested';
result?: string | null;
undo_until?: string | null;
created_at!: string & Opt;
decided_at?: string | null;
}
export const AssistantToolCallsSchema = defineEntity({
class: AssistantToolCalls,
repository: () => AssistantToolCallsRepository,
uniques: [{ properties: ['thread', 'provider_call_id'] }],
properties: {
id: p.text().primary(),
thread: () => p.manyToOne(AssistantThreads).ref().deleteRule('cascade').hidden(),
thread_id: p.integer().persist(false),
message: () => p.manyToOne(AssistantMessages).ref().deleteRule('cascade').hidden().index('idx_assistant_tool_calls_message'),
message_id: p.integer().persist(false).index('idx_assistant_tool_calls_message'),
provider_call_id: p.text(),
tool_name: p.text(),
args: p.text(),
preview: p.text(),
state: p.text().default('approval_requested'),
result: p.text().nullable(),
undo_until: p.type(DbTimestampType).nullable(),
created_at: p.type(DbTimestampType).defaultRaw(`CURRENT_TIMESTAMP`),
decided_at: p.type(DbTimestampType).nullable(),
},
});