@promptbook/utils
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
77 lines (76 loc) • 2.52 kB
TypeScript
/**
* One file an answered agent message created, edited or deleted inside one project.
*
* Note: [🚉] This is fully serializable as JSON
*
* @private internal type of the agent-message runtime
*/
export type AgentMessageProjectChangedFile = {
/**
* Path of the file relative to the project root, using `/` separators.
*/
readonly path: string;
/**
* Count of lines added to the file.
*/
readonly insertionCount: number;
/**
* Count of lines removed from the file.
*/
readonly deletionCount: number;
};
/**
* Everything answering one single message changed inside one agent project.
*
* Each agent project is a git repository and every answer which modifies it is committed there
* automatically, so this describes exactly one such commit — the trace of what one message really
* did to one project, which a chat can show below the answer that did it.
*
* Note: [🚉] This is fully serializable as JSON
*
* @private internal type of the agent-message runtime
*/
export type AgentMessageProjectChange = {
/**
* Directory name of the changed project inside the agent `projects/` folder.
*/
readonly projectName: string;
/**
* Full hash of the commit holding the changes of this message.
*/
readonly commitHash: string;
/**
* ISO 8601 timestamp when the changes were committed.
*/
readonly committedAt: string;
/**
* Files the message changed, ordered as git reports them.
*/
readonly changedFiles: ReadonlyArray<AgentMessageProjectChangedFile>;
/**
* Count of lines added across all changed files.
*/
readonly insertionCount: number;
/**
* Count of lines removed across all changed files.
*/
readonly deletionCount: number;
/**
* Unified diff of the commit, shortened when the change is too large to carry into a chat.
*/
readonly diff: string;
/**
* Whether `diff` holds only the beginning of the real diff.
*/
readonly isDiffTruncated: boolean;
};
/**
* Validates one already-parsed JSON value as a project change.
*
* @param value - Raw serialized project change.
* @returns The typed project change, or `null` when the value does not match the expected shape,
* so consumers can silently skip foreign or malformed entries.
*
* @private internal utility of the agent-message runtime
*/
export declare function normalizeAgentMessageProjectChange(value: unknown): AgentMessageProjectChange | null;