Implement update notion page tool

This commit is contained in:
CREDO23 2026-02-13 10:45:51 +02:00
parent d33c0dd32f
commit 0d1b61d7e6
7 changed files with 254 additions and 329 deletions

View file

@ -7,7 +7,6 @@ export interface ThinkingStepData {
items: string[];
}
export type ContentPart =
| { type: "text"; text: string }
| {
@ -18,24 +17,25 @@ export type ContentPart =
result?: unknown;
};
export interface ContentPartsState {
contentParts: ContentPart[];
currentTextPartIndex: number;
toolCallIndices: Map<string, number>;
}
export function appendText(state: ContentPartsState, delta: string): void {
if (state.currentTextPartIndex >= 0 && state.contentParts[state.currentTextPartIndex]?.type === "text") {
(state.contentParts[state.currentTextPartIndex] as { type: "text"; text: string }).text += delta;
if (
state.currentTextPartIndex >= 0 &&
state.contentParts[state.currentTextPartIndex]?.type === "text"
) {
(state.contentParts[state.currentTextPartIndex] as { type: "text"; text: string }).text +=
delta;
} else {
state.contentParts.push({ type: "text", text: delta });
state.currentTextPartIndex = state.contentParts.length - 1;
}
}
export function addToolCall(
state: ContentPartsState,
toolsWithUI: Set<string>,
@ -55,7 +55,6 @@ export function addToolCall(
}
}
export function updateToolCall(
state: ContentPartsState,
toolCallId: string,
@ -69,7 +68,6 @@ export function updateToolCall(
}
}
export function buildContentForUI(
state: ContentPartsState,
toolsWithUI: Set<string>
@ -84,7 +82,6 @@ export function buildContentForUI(
: [{ type: "text", text: "" }];
}
export function buildContentForPersistence(
state: ContentPartsState,
toolsWithUI: Set<string>,