refactor(packages): localize internal helper types (#101041)

This commit is contained in:
Vincent Koc
2026-07-06 10:30:58 -07:00
committed by GitHub
parent b3e68a093c
commit 65a9cb4ed1
6 changed files with 9 additions and 15 deletions
@@ -32,8 +32,6 @@ export interface BranchSummaryDetails {
modifiedFiles: string[];
}
export type { FileOperations } from "./utils.js";
/** Prepared branch content for summarization. */
export interface BranchPreparation {
/** Messages selected for the branch summary. */
@@ -69,7 +67,7 @@ export interface CollectBranchPathEntriesResult<TEntry extends BranchPathEntry>
}
/** Options for generating a branch summary. */
export interface GenerateBranchSummaryOptions {
interface GenerateBranchSummaryOptions {
/** Model used for summarization. */
model: Model;
/** API key forwarded to the provider. */
@@ -381,7 +381,7 @@ export function findTurnStartIndex(
}
/** Cut point selected for compaction. */
export interface CutPointResult {
interface CutPointResult {
/** Index of the first entry retained after compaction. */
firstKeptEntryIndex: number;
/** Index of the turn-start entry when the cut splits a turn, otherwise -1. */
@@ -3,7 +3,7 @@ import type { Message } from "../types.js";
// Copilot expects X-Initiator to indicate whether the request is user-initiated
// or agent-initiated (e.g. follow-up after assistant/tool messages).
export function inferCopilotInitiator(messages: Message[]): "user" | "agent" {
function inferCopilotInitiator(messages: Message[]): "user" | "agent" {
const last = messages[messages.length - 1];
return last && last.role !== "user" ? "agent" : "user";
}
@@ -26,7 +26,7 @@ type ResponsesFunctionTool = {
strict?: boolean | null;
};
export type ConvertedResponsesTools = {
type ConvertedResponsesTools = {
projection: OpenAIToolProjection;
tools: OpenAITool[];
};
+2 -2
View File
@@ -1,11 +1,11 @@
/** Cached async loader used by runtime boundaries that should import on first use. */
export type LazyPromiseLoader<T> = {
type LazyPromiseLoader<T> = {
load(): Promise<T>;
clear(): void;
};
/** Controls whether a failed first import stays cached or is retried later. */
export type LazyPromiseLoaderOptions = {
type LazyPromiseLoaderOptions = {
cacheRejections?: boolean;
};
+3 -7
View File
@@ -94,7 +94,7 @@ export function findJsonObjectEnd(
}
/** Consumes one optional line break after a repaired serialized tool-call fragment. */
export function skipSerializedToolCallTrailingLineBreak(text: string, cursor: number): number {
function skipSerializedToolCallTrailingLineBreak(text: string, cursor: number): number {
const afterLineBreak = consumeLineBreak(text, cursor);
return afterLineBreak ?? cursor;
}
@@ -174,16 +174,12 @@ export function findHarmonyJsonPayloadStart(text: string): number | null {
}
/** Case-insensitive marker compare for ASCII protocol tags without locale rules. */
export function startsWithAsciiMarkerIgnoreCase(
text: string,
cursor: number,
marker: string,
): boolean {
function startsWithAsciiMarkerIgnoreCase(text: string, cursor: number, marker: string): boolean {
return text.slice(cursor, cursor + marker.length).toLowerCase() === marker;
}
/** Case-insensitive marker search for ASCII protocol tags without allocating regexes. */
export function indexOfAsciiMarkerIgnoreCase(text: string, marker: string, start: number): number {
function indexOfAsciiMarkerIgnoreCase(text: string, marker: string, start: number): number {
let cursor = start;
while (cursor < text.length) {
const next = text.indexOf(marker[0] ?? "", cursor);