import { createTypedValidator } from '@takeshape/json-schema';
import * as agentMessageInput from "./agent-message-input.js";
import * as agentMessageOutput from "./agent-message-output.js";
export const shapeName = 'TSAgentSession';
export const recordSchema = {
    title: shapeName,
    type: 'object',
    properties: {
        id: {
            type: 'string',
            description: 'The unique identifier for the agent session.'
        },
        createdAt: {
            type: 'string',
            description: 'ISO8601 timestamp when the agent session was created',
            format: 'date-time'
        },
        updatedAt: {
            type: 'string',
            description: 'ISO8601 timestamp when the agent session was updated',
            format: 'date-time'
        },
        agentName: {
            type: 'string',
            description: 'The name of the agent associated with this session.'
        },
        projectId: {
            type: 'string',
            description: 'The ID of the project to which this agent session belongs.'
        },
        schemaId: {
            type: 'string',
            description: 'The schema ID associated with the agent session, typically in the format "production~projectId".'
        },
        schemaHash: {
            type: 'string',
            description: 'The hash of the schema version associated with the agent session.'
        },
        done: {
            type: 'boolean',
            description: 'Indicates whether the agent session is completed.'
        },
        suspended: {
            type: 'boolean',
            description: 'Indicates whether the agent session is suspended.'
        },
        previousStateId: {
            type: 'string',
            description: 'The ID of the previous state in the agent session, if any.'
        },
        currentStateId: {
            type: 'string',
            description: 'The ID of the current state in the agent session.'
        },
        chatSessionIds: {
            type: 'object',
            description: 'A mapping of chat session IDs to their corresponding state IDs.'
        },
        sessionMemory: {
            type: 'object',
            description: 'Memory associated with the agent session, which can be used to store stateful information.'
        },
        hasAgentHistory: {
            type: 'boolean',
            description: 'Indicates whether the agent session has an associated history of agent responses.'
        },
        hasFeedback: {
            type: 'boolean',
            description: 'Indicates whether the agent session has any messages with feedback.'
        },
        suspend: {
            type: 'boolean',
            description: 'Indicates whether the agent session is suspended.'
        },
        suspendedTransitionIndices: {
            type: 'array',
            description: 'An array of indices of suspended transitions in the agent session.',
            items: {
                type: 'integer'
            }
        },
        firstMessageInput: {
            ...agentMessageInput.schema
        },
        lastMessageOutput: {
            ...agentMessageOutput.schema
        },
        totalTokens: {
            type: 'number',
            description: 'The total number of tokens used in the agent session.'
        },
        // Below are for records
        __createdRegion: {
            type: 'string'
        },
        __updatedRegion: {
            type: 'string'
        },
        ttl: {
            type: 'integer'
        },
        schemaIdAgentName: {
            type: 'string'
        }
    },
    required: [
        '__createdRegion',
        '__updatedRegion',
        'ttl',
        'schemaIdAgentName',
        'id',
        'agentName',
        'createdAt',
        'updatedAt',
        'done',
        'currentStateId',
        'chatSessionIds',
        'sessionMemory',
        'hasAgentHistory',
        'hasFeedback',
        'suspend',
        'projectId',
        'schemaId',
        'schemaHash',
        'totalTokens'
    ],
    additionalProperties: false
};
const { __createdRegion, __updatedRegion, ttl, schemaIdAgentName, ...schemaProperties } = recordSchema.properties;
export const schema = {
    ...recordSchema,
    properties: {
        ...schemaProperties
    },
    required: [
        'id',
        'agentName',
        'createdAt',
        'updatedAt',
        'done',
        'currentStateId',
        'chatSessionIds',
        'sessionMemory',
        'hasAgentHistory',
        'hasFeedback',
        'suspend',
        'projectId',
        'schemaId',
        'schemaHash',
        'totalTokens'
    ],
    additionalProperties: false
};
export const validate = createTypedValidator(schema);
const { projectId, schemaId, schemaHash, firstMessageInput, lastMessageOutput, suspendedTransitionIndices, chatSessionIds, previousStateId, ...shapeSchemaProperties } = schema.properties;
export const shapeSchema = {
    ...schema,
    properties: {
        ...shapeSchemaProperties
    },
    required: [
        'id',
        'agentName',
        'createdAt',
        'updatedAt',
        'done',
        'sessionMemory',
        'hasAgentHistory',
        'hasFeedback',
        'suspend',
        'currentStateId',
        'totalTokens'
    ],
    additionalProperties: false
};
