refactor: ts in packages/*/tests use extensionless import
This commit is contained in:
@@ -3,7 +3,7 @@ import { mkdtemp, rm } from 'node:fs/promises'
|
|||||||
import { tmpdir } from 'node:os'
|
import { tmpdir } from 'node:os'
|
||||||
import { join } from 'node:path'
|
import { join } from 'node:path'
|
||||||
import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk'
|
import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk'
|
||||||
import { makeBridgeHarness, textResponse, type BridgeHarness } from './harness.ts'
|
import { makeBridgeHarness, textResponse, type BridgeHarness } from './harness'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* End-to-end bridge specs over an in-memory transport: a real
|
* End-to-end bridge specs over an in-memory transport: a real
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
harnessBlockToAcpContent,
|
harnessBlockToAcpContent,
|
||||||
promptHasUnsupportedContent,
|
promptHasUnsupportedContent,
|
||||||
turnEndToStopReason,
|
turnEndToStopReason,
|
||||||
} from '../src/codec.ts'
|
} from '../src/codec'
|
||||||
|
|
||||||
describe('turnEndToStopReason', () => {
|
describe('turnEndToStopReason', () => {
|
||||||
// The SDK rejects an unknown stopReason, so this must be total over every
|
// The SDK rejects an unknown stopReason, so this must be total over every
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { mkdtemp, rm } from 'node:fs/promises'
|
|||||||
import { tmpdir } from 'node:os'
|
import { tmpdir } from 'node:os'
|
||||||
import { join } from 'node:path'
|
import { join } from 'node:path'
|
||||||
import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk'
|
import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk'
|
||||||
import { makeBridgeHarness } from './harness.ts'
|
import { makeBridgeHarness } from './harness'
|
||||||
|
|
||||||
describe('acp bridge — disposal & HMR safety', () => {
|
describe('acp bridge — disposal & HMR safety', () => {
|
||||||
let storageDir: string
|
let storageDir: string
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { mkdtemp, rm } from 'node:fs/promises'
|
|||||||
import { tmpdir } from 'node:os'
|
import { tmpdir } from 'node:os'
|
||||||
import { join } from 'node:path'
|
import { join } from 'node:path'
|
||||||
import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk'
|
import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk'
|
||||||
import { makeBridgeHarness, textResponse, type BridgeHarness } from './harness.ts'
|
import { makeBridgeHarness, textResponse, type BridgeHarness } from './harness'
|
||||||
|
|
||||||
describe('acp bridge — demux & config edges', () => {
|
describe('acp bridge — demux & config edges', () => {
|
||||||
let storageDir: string
|
let storageDir: string
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ import {
|
|||||||
type SessionNotification,
|
type SessionNotification,
|
||||||
type Stream,
|
type Stream,
|
||||||
} from '@agentclientprotocol/sdk'
|
} from '@agentclientprotocol/sdk'
|
||||||
import * as AcpPlugin from '../src/index.ts'
|
import * as AcpPlugin from '../src/index'
|
||||||
import { type AcpConfig } from '../src/index.ts'
|
import { type AcpConfig } from '../src/index'
|
||||||
|
|
||||||
/** A scripted mock adapter (mirrors the agent-loop test adapter). */
|
/** A scripted mock adapter (mirrors the agent-loop test adapter). */
|
||||||
class MockAdapter extends LlmAdapter {
|
class MockAdapter extends LlmAdapter {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { tmpdir } from 'node:os'
|
|||||||
import { join } from 'node:path'
|
import { join } from 'node:path'
|
||||||
import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk'
|
import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk'
|
||||||
import { SessionId } from '@deepseek-ai/dsh-session'
|
import { SessionId } from '@deepseek-ai/dsh-session'
|
||||||
import { makeBridgeHarness, textResponse, toolCallResponse, type BridgeHarness, type CapturedUpdate } from './harness.ts'
|
import { makeBridgeHarness, textResponse, toolCallResponse, type BridgeHarness, type CapturedUpdate } from './harness'
|
||||||
|
|
||||||
/** Concatenate the text of all agent_message_chunk updates. */
|
/** Concatenate the text of all agent_message_chunk updates. */
|
||||||
function messageText(updates: CapturedUpdate[]): string {
|
function messageText(updates: CapturedUpdate[]): string {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { mkdtemp, rm } from 'node:fs/promises'
|
|||||||
import { tmpdir } from 'node:os'
|
import { tmpdir } from 'node:os'
|
||||||
import { join } from 'node:path'
|
import { join } from 'node:path'
|
||||||
import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk'
|
import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk'
|
||||||
import { makeBridgeHarness, textResponse, type BridgeHarness, type CapturedUpdate } from './harness.ts'
|
import { makeBridgeHarness, textResponse, type BridgeHarness, type CapturedUpdate } from './harness'
|
||||||
|
|
||||||
/** Text of the agent_message_chunk updates scoped to one session id. */
|
/** Text of the agent_message_chunk updates scoped to one session id. */
|
||||||
function messageTextFor(updates: { sessionId?: string; update: CapturedUpdate }[], sessionId: string): string {
|
function messageTextFor(updates: { sessionId?: string; update: CapturedUpdate }[], sessionId: string): string {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import fc from 'fast-check'
|
|||||||
import { CallId } from '@deepseek-ai/dsh-llm'
|
import { CallId } from '@deepseek-ai/dsh-llm'
|
||||||
import type { SessionEvent } from '@deepseek-ai/dsh-session'
|
import type { SessionEvent } from '@deepseek-ai/dsh-session'
|
||||||
import type { SessionNotification } from '@agentclientprotocol/sdk'
|
import type { SessionNotification } from '@agentclientprotocol/sdk'
|
||||||
import { streamSessionEventUpdate } from '../src/index.ts'
|
import { streamSessionEventUpdate } from '../src/index'
|
||||||
|
|
||||||
const LEGAL_UPDATE_KINDS = new Set([
|
const LEGAL_UPDATE_KINDS = new Set([
|
||||||
'agent_message_chunk',
|
'agent_message_chunk',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { CallId } from '@deepseek-ai/dsh-llm'
|
|||||||
import type { SessionEvent } from '@deepseek-ai/dsh-session'
|
import type { SessionEvent } from '@deepseek-ai/dsh-session'
|
||||||
import type { SessionNotification } from '@agentclientprotocol/sdk'
|
import type { SessionNotification } from '@agentclientprotocol/sdk'
|
||||||
import type { ToolDefinition, ToolRegistry } from '@deepseek-ai/dsh-tools'
|
import type { ToolDefinition, ToolRegistry } from '@deepseek-ai/dsh-tools'
|
||||||
import { streamSessionEventUpdate, agentOptions, ToolPresenter } from '../src/index.ts'
|
import { streamSessionEventUpdate, agentOptions, ToolPresenter } from '../src/index'
|
||||||
|
|
||||||
/** Collect the updates a single event produces (no presenter → generic fallback). */
|
/** Collect the updates a single event produces (no presenter → generic fallback). */
|
||||||
function updatesFor(event: SessionEvent): SessionNotification['update'][] {
|
function updatesFor(event: SessionEvent): SessionNotification['update'][] {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
textResponse,
|
textResponse,
|
||||||
toolCallResponse,
|
toolCallResponse,
|
||||||
type BridgeHarness,
|
type BridgeHarness,
|
||||||
} from './harness.ts'
|
} from './harness'
|
||||||
|
|
||||||
/** Boilerplate: initialize + create one session, returning its id. */
|
/** Boilerplate: initialize + create one session, returning its id. */
|
||||||
async function newSession(h: BridgeHarness, clientCapabilities: Record<string, unknown> = {}): Promise<string> {
|
async function newSession(h: BridgeHarness, clientCapabilities: Record<string, unknown> = {}): Promise<string> {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
|
|||||||
import ToolRegistry from '@deepseek-ai/dsh-tools'
|
import ToolRegistry from '@deepseek-ai/dsh-tools'
|
||||||
import AgentRegistry from '@deepseek-ai/dsh-agent'
|
import AgentRegistry from '@deepseek-ai/dsh-agent'
|
||||||
import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop'
|
import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop'
|
||||||
import { MockAdapter, textResponse } from './mock-adapter.ts'
|
import { MockAdapter, textResponse } from './mock-adapter'
|
||||||
|
|
||||||
async function harness(adapter: MockAdapter) {
|
async function harness(adapter: MockAdapter) {
|
||||||
const ctx = new Context()
|
const ctx = new Context()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import ToolRegistry from '@deepseek-ai/dsh-tools'
|
|||||||
import AgentRegistry from '@deepseek-ai/dsh-agent'
|
import AgentRegistry from '@deepseek-ai/dsh-agent'
|
||||||
import SessionPersistenceJsonl from '@deepseek-ai/dsh-session-persistence-jsonl'
|
import SessionPersistenceJsonl from '@deepseek-ai/dsh-session-persistence-jsonl'
|
||||||
import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop'
|
import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop'
|
||||||
import { MockAdapter, textResponse } from './mock-adapter.ts'
|
import { MockAdapter, textResponse } from './mock-adapter'
|
||||||
|
|
||||||
const dirs: string[] = []
|
const dirs: string[] = []
|
||||||
afterEach(async () => { for (const d of dirs.splice(0)) await rm(d, { recursive: true, force: true }) })
|
afterEach(async () => { for (const d of dirs.splice(0)) await rm(d, { recursive: true, force: true }) })
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
|
|||||||
import ToolRegistry, { defineTool } from '@deepseek-ai/dsh-tools'
|
import ToolRegistry, { defineTool } from '@deepseek-ai/dsh-tools'
|
||||||
import AgentRegistry from '@deepseek-ai/dsh-agent'
|
import AgentRegistry from '@deepseek-ai/dsh-agent'
|
||||||
import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop'
|
import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop'
|
||||||
import { MockAdapter, textResponse, toolCallResponse } from './mock-adapter.ts'
|
import { MockAdapter, textResponse, toolCallResponse } from './mock-adapter'
|
||||||
|
|
||||||
async function harness(adapter: MockAdapter) {
|
async function harness(adapter: MockAdapter) {
|
||||||
const ctx = new Context()
|
const ctx = new Context()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
|
|||||||
import ToolRegistry, { defineTool } from '@deepseek-ai/dsh-tools'
|
import ToolRegistry, { defineTool } from '@deepseek-ai/dsh-tools'
|
||||||
import AgentRegistry from '@deepseek-ai/dsh-agent'
|
import AgentRegistry from '@deepseek-ai/dsh-agent'
|
||||||
import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop'
|
import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop'
|
||||||
import { MockAdapter, maxTokensResponse, textResponse, toolCallResponse } from './mock-adapter.ts'
|
import { MockAdapter, maxTokensResponse, textResponse, toolCallResponse } from './mock-adapter'
|
||||||
|
|
||||||
async function harness(adapter: MockAdapter) {
|
async function harness(adapter: MockAdapter) {
|
||||||
const ctx = new Context()
|
const ctx = new Context()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import ToolRegistry from '@deepseek-ai/dsh-tools'
|
|||||||
import AgentRegistry from '@deepseek-ai/dsh-agent'
|
import AgentRegistry from '@deepseek-ai/dsh-agent'
|
||||||
import SessionPersistenceJsonl from '@deepseek-ai/dsh-session-persistence-jsonl'
|
import SessionPersistenceJsonl from '@deepseek-ai/dsh-session-persistence-jsonl'
|
||||||
import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop'
|
import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop'
|
||||||
import { MockAdapter, textResponse } from './mock-adapter.ts'
|
import { MockAdapter, textResponse } from './mock-adapter'
|
||||||
|
|
||||||
const dirs: string[] = []
|
const dirs: string[] = []
|
||||||
afterEach(async () => { for (const d of dirs.splice(0)) await rm(d, { recursive: true, force: true }) })
|
afterEach(async () => { for (const d of dirs.splice(0)) await rm(d, { recursive: true, force: true }) })
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import ToolRegistry, { defineTool } from '@deepseek-ai/dsh-tools'
|
|||||||
import AgentRegistry, { AgentId } from '@deepseek-ai/dsh-agent'
|
import AgentRegistry, { AgentId } from '@deepseek-ai/dsh-agent'
|
||||||
import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop'
|
import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop'
|
||||||
import * as Invariants from '@deepseek-ai/dsh-invariants'
|
import * as Invariants from '@deepseek-ai/dsh-invariants'
|
||||||
import { MockAdapter, textResponse, toolCallResponse } from './mock-adapter.ts'
|
import { MockAdapter, textResponse, toolCallResponse } from './mock-adapter'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regression tests for the findings of the first architecture review
|
* Regression tests for the findings of the first architecture review
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
loadReplayScript,
|
loadReplayScript,
|
||||||
name,
|
name,
|
||||||
parseSessionLog,
|
parseSessionLog,
|
||||||
} from '../src/index.ts'
|
} from '../src/index'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for the replay llm/stream plugin. These drive the listener through
|
* Unit tests for the replay llm/stream plugin. These drive the listener through
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import { join } from 'node:path'
|
|||||||
import SessionStore, { SessionId } from '@deepseek-ai/dsh-session'
|
import SessionStore, { SessionId } from '@deepseek-ai/dsh-session'
|
||||||
import type { Session, SessionEvent, SessionMeta } from '@deepseek-ai/dsh-session'
|
import type { Session, SessionEvent, SessionMeta } from '@deepseek-ai/dsh-session'
|
||||||
import SessionPersistenceJsonl from '@deepseek-ai/dsh-session-persistence-jsonl'
|
import SessionPersistenceJsonl from '@deepseek-ai/dsh-session-persistence-jsonl'
|
||||||
import { encodeSegment, logPath, scanLog, sessionDir, sidecarPath } from '../src/format.ts'
|
import { encodeSegment, logPath, scanLog, sessionDir, sidecarPath } from '../src/format'
|
||||||
import { runPersistenceContract, meta, oneTurnLog } from '../../session-persistence/tests/contract.ts'
|
import { runPersistenceContract, meta, oneTurnLog } from '../../session-persistence/tests/contract'
|
||||||
|
|
||||||
let root: string
|
let root: string
|
||||||
const dirs: string[] = []
|
const dirs: string[] = []
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import { join } from 'node:path'
|
|||||||
import SessionStore, { SessionId } from '@deepseek-ai/dsh-session'
|
import SessionStore, { SessionId } from '@deepseek-ai/dsh-session'
|
||||||
import type { Session, SessionEvent, SessionMeta } from '@deepseek-ai/dsh-session'
|
import type { Session, SessionEvent, SessionMeta } from '@deepseek-ai/dsh-session'
|
||||||
import SessionPersistenceSqlite, { SCHEMA_VERSION } from '@deepseek-ai/dsh-session-persistence-sqlite'
|
import SessionPersistenceSqlite, { SCHEMA_VERSION } from '@deepseek-ai/dsh-session-persistence-sqlite'
|
||||||
import { openDatabase, scanRows, type EventRow } from '../src/schema.ts'
|
import { openDatabase, scanRows, type EventRow } from '../src/schema'
|
||||||
import { runPersistenceContract, meta, oneTurnLog } from '../../session-persistence/tests/contract.ts'
|
import { runPersistenceContract, meta, oneTurnLog } from '../../session-persistence/tests/contract'
|
||||||
|
|
||||||
const dirs: string[] = []
|
const dirs: string[] = []
|
||||||
afterEach(async () => { for (const d of dirs.splice(0)) await rm(d, { recursive: true, force: true }) })
|
afterEach(async () => { for (const d of dirs.splice(0)) await rm(d, { recursive: true, force: true }) })
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { describe, expect, it, vi } from 'vitest'
|
|||||||
import { SessionId } from '@deepseek-ai/dsh-session'
|
import { SessionId } from '@deepseek-ai/dsh-session'
|
||||||
import type { SessionEvent, SessionMeta } from '@deepseek-ai/dsh-session'
|
import type { SessionEvent, SessionMeta } from '@deepseek-ai/dsh-session'
|
||||||
import { CallId } from '@deepseek-ai/dsh-llm'
|
import { CallId } from '@deepseek-ai/dsh-llm'
|
||||||
import type { SessionPersistence } from '../src/index.ts'
|
import type { SessionPersistence } from '../src/index'
|
||||||
|
|
||||||
/** A backend under test plus its teardown. */
|
/** A backend under test plus its teardown. */
|
||||||
export interface ContractBackend {
|
export interface ContractBackend {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { describe, expect, it } from 'vitest'
|
|||||||
import { Context } from 'cordis'
|
import { Context } from 'cordis'
|
||||||
import { SessionId, isJsonValue, interruptedTurnClosers } from '@deepseek-ai/dsh-session'
|
import { SessionId, isJsonValue, interruptedTurnClosers } from '@deepseek-ai/dsh-session'
|
||||||
import type { SessionEvent, SessionMeta, SessionSummary } from '@deepseek-ai/dsh-session'
|
import type { SessionEvent, SessionMeta, SessionSummary } from '@deepseek-ai/dsh-session'
|
||||||
import { SessionPersistence, assertSerializable, seedCoversPrefix } from '../src/index.ts'
|
import { SessionPersistence, assertSerializable, seedCoversPrefix } from '../src/index'
|
||||||
import { runPersistenceContract, meta, oneTurnLog } from './contract.ts'
|
import { runPersistenceContract, meta, oneTurnLog } from './contract'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A minimal in-memory {@link SessionPersistence} used to (a) cover the abstract
|
* A minimal in-memory {@link SessionPersistence} used to (a) cover the abstract
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { describe, expect, it } from 'vitest'
|
import { describe, expect, it } from 'vitest'
|
||||||
import { CallId } from '@deepseek-ai/dsh-llm'
|
import { CallId } from '@deepseek-ai/dsh-llm'
|
||||||
import { interruptedTurnClosers } from '../src/index.ts'
|
import { interruptedTurnClosers } from '../src/index'
|
||||||
import type { SessionEvent } from '../src/index.ts'
|
import type { SessionEvent } from '../src/index'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit coverage for the crash-recovery closer synthesis. The persistence
|
* Unit coverage for the crash-recovery closer synthesis. The persistence
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import AgentRegistry from '@deepseek-ai/dsh-agent'
|
|||||||
import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop'
|
import AgentLoop, { ReactLoopAgent } from '@deepseek-ai/dsh-agent-loop'
|
||||||
import { LocalBashExecutor } from '@deepseek-ai/dsh-bash-local'
|
import { LocalBashExecutor } from '@deepseek-ai/dsh-bash-local'
|
||||||
import * as ToolBash from '@deepseek-ai/dsh-tool-bash'
|
import * as ToolBash from '@deepseek-ai/dsh-tool-bash'
|
||||||
import { MockAdapter, textResponse, toolCallResponse } from '../../agent-loop/tests/mock-adapter.ts'
|
import { MockAdapter, textResponse, toolCallResponse } from '../../agent-loop/tests/mock-adapter'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Full-loop integration: a scripted mock model drives the REAL bash tool
|
* Full-loop integration: a scripted mock model drives the REAL bash tool
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import type { Agent, AgentStatus } from '@deepseek-ai/dsh-agent'
|
|||||||
import AgentRegistry from '@deepseek-ai/dsh-agent'
|
import AgentRegistry from '@deepseek-ai/dsh-agent'
|
||||||
import type { ContentBlock } from '@deepseek-ai/dsh-llm'
|
import type { ContentBlock } from '@deepseek-ai/dsh-llm'
|
||||||
import type { Session, SessionEvent } from '@deepseek-ai/dsh-session'
|
import type { Session, SessionEvent } from '@deepseek-ai/dsh-session'
|
||||||
import { createStdioChat, type Config, type StdioRuntime } from '../src/index.ts'
|
import { createStdioChat, type Config, type StdioRuntime } from '../src/index'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for the stdio UI plugin. They drive the REAL plugin body
|
* Unit tests for the stdio UI plugin. They drive the REAL plugin body
|
||||||
|
|||||||
Reference in New Issue
Block a user