chore(ts): use source import extensions

This commit is contained in:
Armin Ronacher
2026-05-20 00:04:03 +02:00
parent 06c6c324d7
commit ae9450dc51
259 changed files with 1483 additions and 1300 deletions

View File

@@ -20,7 +20,7 @@ import type {
AgentToolCall,
AgentToolResult,
StreamFn,
} from "./types.js";
} from "./types.ts";
export type AgentEventSink = (event: AgentEvent) => Promise<void> | void;

View File

@@ -8,7 +8,7 @@ import {
type ThinkingBudgets,
type Transport,
} from "@earendil-works/pi-ai";
import { runAgentLoop, runAgentLoopContinue } from "./agent-loop.js";
import { runAgentLoop, runAgentLoopContinue } from "./agent-loop.ts";
import type {
AfterToolCallContext,
AfterToolCallResult,
@@ -24,9 +24,9 @@ import type {
QueueMode,
StreamFn,
ToolExecutionMode,
} from "./types.js";
} from "./types.ts";
export type { QueueMode } from "./types.js";
export type { QueueMode } from "./types.ts";
function defaultConvertToLlm(messages: AgentMessage[]): Message[] {
return messages.filter(

View File

@@ -5,7 +5,7 @@ import {
streamSimple,
type UserMessage,
} from "@earendil-works/pi-ai";
import { runAgentLoop } from "../agent-loop.js";
import { runAgentLoop } from "../agent-loop.ts";
import type {
AgentContext,
AgentEvent,
@@ -15,12 +15,12 @@ import type {
QueueMode,
StreamFn,
ThinkingLevel,
} from "../types.js";
import { collectEntriesForBranchSummary, generateBranchSummary } from "./compaction/branch-summarization.js";
import { compact, DEFAULT_COMPACTION_SETTINGS, prepareCompaction } from "./compaction/compaction.js";
import { convertToLlm } from "./messages.js";
import { formatPromptTemplateInvocation } from "./prompt-templates.js";
import { formatSkillInvocation } from "./skills.js";
} from "../types.ts";
import { collectEntriesForBranchSummary, generateBranchSummary } from "./compaction/branch-summarization.ts";
import { compact, DEFAULT_COMPACTION_SETTINGS, prepareCompaction } from "./compaction/compaction.ts";
import { convertToLlm } from "./messages.ts";
import { formatPromptTemplateInvocation } from "./prompt-templates.ts";
import { formatSkillInvocation } from "./skills.ts";
import type {
AbortResult,
AgentHarnessEvent,
@@ -37,8 +37,8 @@ import type {
PromptTemplate,
Session,
Skill,
} from "./types.js";
import { AgentHarnessError, BranchSummaryError, CompactionError, SessionError, toError } from "./types.js";
} from "./types.ts";
import { AgentHarnessError, BranchSummaryError, CompactionError, SessionError, toError } from "./types.ts";
function createUserMessage(text: string, images?: ImageContent[]): UserMessage {
const content: Array<{ type: "text"; text: string } | ImageContent> = [{ type: "text", text }];

View File

@@ -1,15 +1,15 @@
import type { Model } from "@earendil-works/pi-ai";
import { completeSimple } from "@earendil-works/pi-ai";
import type { AgentMessage } from "../../types.js";
import type { AgentMessage } from "../../types.ts";
import {
convertToLlm,
createBranchSummaryMessage,
createCompactionSummaryMessage,
createCustomMessage,
} from "../messages.js";
import type { BranchSummaryResult, Session, SessionTreeEntry } from "../types.js";
import { BranchSummaryError, err, ok, type Result, SessionError } from "../types.js";
import { estimateTokens, SUMMARIZATION_SYSTEM_PROMPT } from "./compaction.js";
} from "../messages.ts";
import type { BranchSummaryResult, Session, SessionTreeEntry } from "../types.ts";
import { BranchSummaryError, err, ok, type Result, SessionError } from "../types.ts";
import { estimateTokens, SUMMARIZATION_SYSTEM_PROMPT } from "./compaction.ts";
import {
computeFileLists,
createFileOps,
@@ -17,7 +17,7 @@ import {
type FileOperations,
formatFileOperations,
serializeConversation,
} from "./utils.js";
} from "./utils.ts";
/** File-operation details stored on generated branch summary entries. */
export interface BranchSummaryDetails {
@@ -27,7 +27,7 @@ export interface BranchSummaryDetails {
modifiedFiles: string[];
}
export type { FileOperations } from "./utils.js";
export type { FileOperations } from "./utils.ts";
/** Prepared branch content for summarization. */
export interface BranchPreparation {

View File

@@ -1,14 +1,14 @@
import type { AssistantMessage, ImageContent, Model, TextContent, Usage } from "@earendil-works/pi-ai";
import { completeSimple } from "@earendil-works/pi-ai";
import type { AgentMessage, ThinkingLevel } from "../../types.js";
import type { AgentMessage, ThinkingLevel } from "../../types.ts";
import {
convertToLlm,
createBranchSummaryMessage,
createCompactionSummaryMessage,
createCustomMessage,
} from "../messages.js";
import { buildSessionContext } from "../session/session.js";
import { type CompactionEntry, CompactionError, err, ok, type Result, type SessionTreeEntry } from "../types.js";
} from "../messages.ts";
import { buildSessionContext } from "../session/session.ts";
import { type CompactionEntry, CompactionError, err, ok, type Result, type SessionTreeEntry } from "../types.ts";
import {
computeFileLists,
createFileOps,
@@ -16,7 +16,7 @@ import {
type FileOperations,
formatFileOperations,
serializeConversation,
} from "./utils.js";
} from "./utils.ts";
/** File-operation details stored on generated compaction entries. */
export interface CompactionDetails {
@@ -620,7 +620,7 @@ Summarize the prefix to provide context for the retained suffix:
Be concise. Focus on what's needed to understand the kept suffix.`;
export { serializeConversation } from "./utils.js";
export { serializeConversation } from "./utils.ts";
/** Generate compaction summary data from prepared session history. */
export async function compact(

View File

@@ -1,5 +1,5 @@
import type { Message } from "@earendil-works/pi-ai";
import type { AgentMessage } from "../../types.js";
import type { AgentMessage } from "../../types.ts";
/** File paths touched by a session branch or compaction range. */
export interface FileOperations {

View File

@@ -26,7 +26,7 @@ import {
ok,
type Result,
toError,
} from "../types.js";
} from "../types.ts";
function resolvePath(cwd: string, path: string): string {
return isAbsolute(path) ? path : resolve(cwd, path);

View File

@@ -1,5 +1,5 @@
import type { ImageContent, Message, TextContent } from "@earendil-works/pi-ai";
import type { AgentMessage } from "../types.js";
import type { AgentMessage } from "../types.ts";
export const COMPACTION_SUMMARY_PREFIX = `The conversation history before this point was compacted into the following summary:
@@ -51,7 +51,7 @@ export interface CompactionSummaryMessage {
timestamp: number;
}
declare module "../types.js" {
declare module "../types.ts" {
interface CustomAgentMessages {
bashExecution: BashExecutionMessage;
custom: CustomMessage;

View File

@@ -1,5 +1,5 @@
import { parse } from "yaml";
import { type ExecutionEnv, type FileInfo, type PromptTemplate, type Result, toError } from "./types.js";
import { type ExecutionEnv, type FileInfo, type PromptTemplate, type Result, toError } from "./types.ts";
export type PromptTemplateDiagnosticCode = "file_info_failed" | "list_failed" | "read_failed" | "parse_failed";

View File

@@ -5,16 +5,16 @@ import type {
JsonlSessionMetadata,
JsonlSessionRepoApi,
Session,
} from "../types.js";
import { SessionError, toError } from "../types.js";
import { JsonlSessionStorage, loadJsonlSessionMetadata } from "./jsonl-storage.js";
} from "../types.ts";
import { SessionError, toError } from "../types.ts";
import { JsonlSessionStorage, loadJsonlSessionMetadata } from "./jsonl-storage.ts";
import {
createSessionId,
createTimestamp,
getEntriesToFork,
getFileSystemResultOrThrow,
toSession,
} from "./repo-utils.js";
} from "./repo-utils.ts";
type JsonlSessionRepoFileSystem = Pick<
FileSystem,

View File

@@ -1,7 +1,7 @@
import type { FileSystem, JsonlSessionMetadata, LeafEntry, SessionStorage, SessionTreeEntry } from "../types.js";
import { SessionError, toError } from "../types.js";
import { getFileSystemResultOrThrow } from "./repo-utils.js";
import { uuidv7 } from "./uuid.js";
import type { FileSystem, JsonlSessionMetadata, LeafEntry, SessionStorage, SessionTreeEntry } from "../types.ts";
import { SessionError, toError } from "../types.ts";
import { getFileSystemResultOrThrow } from "./repo-utils.ts";
import { uuidv7 } from "./uuid.ts";
type JsonlSessionStorageFileSystem = Pick<FileSystem, "readTextFile" | "readTextLines" | "writeFile" | "appendFile">;

View File

@@ -1,6 +1,6 @@
import { type Session, SessionError, type SessionMetadata, type SessionRepo } from "../types.js";
import { InMemorySessionStorage } from "./memory-storage.js";
import { createSessionId, createTimestamp, getEntriesToFork, toSession } from "./repo-utils.js";
import { type Session, SessionError, type SessionMetadata, type SessionRepo } from "../types.ts";
import { InMemorySessionStorage } from "./memory-storage.ts";
import { createSessionId, createTimestamp, getEntriesToFork, toSession } from "./repo-utils.ts";
export class InMemorySessionRepo implements SessionRepo<SessionMetadata, { id?: string }, void> {
private sessions = new Map<string, Session<SessionMetadata>>();

View File

@@ -4,8 +4,8 @@ import {
type SessionMetadata,
type SessionStorage,
type SessionTreeEntry,
} from "../types.js";
import { uuidv7 } from "./uuid.js";
} from "../types.ts";
import { uuidv7 } from "./uuid.ts";
function updateLabelCache(labelsById: Map<string, string>, entry: SessionTreeEntry): void {
if (entry.type !== "label") return;

View File

@@ -5,9 +5,9 @@ import {
type SessionMetadata,
type SessionStorage,
type SessionTreeEntry,
} from "../types.js";
import { Session } from "./session.js";
import { uuidv7 } from "./uuid.js";
} from "../types.ts";
import { Session } from "./session.ts";
import { uuidv7 } from "./uuid.ts";
export function createSessionId(): string {
return uuidv7();

View File

@@ -1,6 +1,6 @@
import type { ImageContent, TextContent } from "@earendil-works/pi-ai";
import type { AgentMessage } from "../../types.js";
import { createBranchSummaryMessage, createCompactionSummaryMessage, createCustomMessage } from "../messages.js";
import type { AgentMessage } from "../../types.ts";
import { createBranchSummaryMessage, createCompactionSummaryMessage, createCustomMessage } from "../messages.ts";
import type {
BranchSummaryEntry,
CompactionEntry,
@@ -15,8 +15,8 @@ import type {
SessionStorage,
SessionTreeEntry,
ThinkingLevelChangeEntry,
} from "../types.js";
import { SessionError } from "../types.js";
} from "../types.ts";
import { SessionError } from "../types.ts";
export function buildSessionContext(pathEntries: SessionTreeEntry[]): SessionContext {
let thinkingLevel = "off";

View File

@@ -1,6 +1,6 @@
import ignore from "ignore";
import { parse } from "yaml";
import { type ExecutionEnv, type FileInfo, type Result, type Skill, toError } from "./types.js";
import { type ExecutionEnv, type FileInfo, type Result, type Skill, toError } from "./types.ts";
const MAX_NAME_LENGTH = 64;
const MAX_DESCRIPTION_LENGTH = 1024;

View File

@@ -1,4 +1,4 @@
import type { Skill } from "./types.js";
import type { Skill } from "./types.ts";
export function formatSkillsForSystemPrompt(skills: Skill[]): string {
const visibleSkills = skills.filter((skill) => !skill.disableModelInvocation);

View File

@@ -1,6 +1,6 @@
import type { ImageContent, Model, SimpleStreamOptions, TextContent, Transport } from "@earendil-works/pi-ai";
import type { AgentEvent, AgentMessage, AgentTool, QueueMode, ThinkingLevel } from "../index.js";
import type { Session } from "./session/session.js";
import type { AgentEvent, AgentMessage, AgentTool, QueueMode, ThinkingLevel } from "../index.ts";
import type { Session } from "./session/session.ts";
/** Result of a fallible operation. Expected failures are returned as `ok: false` instead of thrown. */
export type Result<TValue, TError> = { ok: true; value: TValue } | { ok: false; error: TError };
@@ -446,7 +446,7 @@ export interface SessionStorage<TMetadata extends SessionMetadata = SessionMetad
getEntries(): Promise<SessionTreeEntry[]>;
}
export type { Session } from "./session/session.js";
export type { Session } from "./session/session.ts";
export interface SessionCreateOptions {
id?: string;
@@ -812,4 +812,4 @@ export interface AgentHarnessOptions<
followUpMode?: QueueMode;
}
export type { AgentHarness } from "./agent-harness.js";
export type { AgentHarness } from "./agent-harness.ts";

View File

@@ -6,8 +6,8 @@ import {
ok,
type Result,
toError,
} from "../types.js";
import { DEFAULT_MAX_BYTES, truncateTail } from "./truncate.js";
} from "../types.ts";
import { DEFAULT_MAX_BYTES, truncateTail } from "./truncate.ts";
export interface ShellCaptureOptions extends Omit<ExecutionEnvExecOptions, "onStdout" | "onStderr"> {
onChunk?: (chunk: string) => void;

View File

@@ -1,8 +1,8 @@
// Core Agent
export * from "./agent.js";
export * from "./agent.ts";
// Loop functions
export * from "./agent-loop.js";
export * from "./harness/agent-harness.js";
export * from "./agent-loop.ts";
export * from "./harness/agent-harness.ts";
export {
type BranchPreparation,
type BranchSummaryDetails,
@@ -10,7 +10,7 @@ export {
collectEntriesForBranchSummary,
generateBranchSummary,
prepareBranchEntries,
} from "./harness/compaction/branch-summarization.js";
} from "./harness/compaction/branch-summarization.ts";
export {
calculateContextTokens,
compact,
@@ -24,21 +24,21 @@ export {
prepareCompaction,
serializeConversation,
shouldCompact,
} from "./harness/compaction/compaction.js";
export * from "./harness/messages.js";
export * from "./harness/prompt-templates.js";
export * from "./harness/session/jsonl-repo.js";
export * from "./harness/session/memory-repo.js";
export * from "./harness/session/repo-utils.js";
export * from "./harness/session/session.js";
export { uuidv7 } from "./harness/session/uuid.js";
export * from "./harness/skills.js";
export * from "./harness/system-prompt.js";
} from "./harness/compaction/compaction.ts";
export * from "./harness/messages.ts";
export * from "./harness/prompt-templates.ts";
export * from "./harness/session/jsonl-repo.ts";
export * from "./harness/session/memory-repo.ts";
export * from "./harness/session/repo-utils.ts";
export * from "./harness/session/session.ts";
export { uuidv7 } from "./harness/session/uuid.ts";
export * from "./harness/skills.ts";
export * from "./harness/system-prompt.ts";
// Harness
export * from "./harness/types.js";
export * from "./harness/utils/shell-output.js";
export * from "./harness/utils/truncate.js";
export * from "./harness/types.ts";
export * from "./harness/utils/shell-output.ts";
export * from "./harness/utils/truncate.ts";
// Proxy utilities
export * from "./proxy.js";
export * from "./proxy.ts";
// Types
export * from "./types.js";
export * from "./types.ts";

View File

@@ -1,2 +1,2 @@
export { NodeExecutionEnv } from "./harness/env/nodejs.js";
export * from "./index.js";
export { NodeExecutionEnv } from "./harness/env/nodejs.ts";
export * from "./index.ts";