Remove Ask/Execute modes and general product tool approvals so requests use the selected runtime, enabled capabilities, and execution account permissions. Migrate retired application metadata while preserving user content. Retire the Results page while retaining conversation images and stored artifacts. Add local and remote workspace file imports, timestamps and sorting, improve image discovery and saving, and refine workspace navigation and supervision responsiveness. Include the accompanying web-search changes, tests, probes, and product documentation. Remote imports require an updated Agent. Existing artifacts are not automatically copied into project directories. Validation evidence and outstanding failures remain documented in feature progress files; no full test suite or real-model calls were rerun for this commit. Release note: Run requests without switching work modes, import files into a selected local or remote workspace folder, sort workspace files by date, and keep using conversation images after removal of the Results page.
682 lines
20 KiB
TypeScript
682 lines
20 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
import type {
|
|
AgentEvent,
|
|
AgentRequest,
|
|
AgentRuntimeStatus
|
|
} from '../../shared/contracts'
|
|
import type { AgentRuntime, RuntimeAuthorizer } from './runtime'
|
|
import {
|
|
AgentRuntimeController,
|
|
MAX_DRAINING_RUNTIME_GENERATIONS,
|
|
RuntimeReplacementCapacityError
|
|
} from './runtime-controller'
|
|
|
|
it('routes a shared request question to its original Runtime across replacement', async () => {
|
|
let release!: () => void
|
|
const gate = new Promise<void>(resolve => { release = resolve })
|
|
const previous: AgentRuntime = {
|
|
sharedProcess: true, requiresToolApproval: false, supportsToolExecution: true,
|
|
getStatus: vi.fn(), dispose: vi.fn(async () => undefined),
|
|
respondToQuestion: vi.fn(async () => undefined),
|
|
async *run(request) {
|
|
yield { type: 'question', requestId: request.requestId, questionId: 'question-old', questions: [] }
|
|
await gate
|
|
yield { type: 'done', requestId: request.requestId }
|
|
}
|
|
}
|
|
const next: AgentRuntime = { ...previous, respondToQuestion: vi.fn(async () => undefined) }
|
|
const controller = new AgentRuntimeController(previous, 1)
|
|
const stream = controller.run({
|
|
requestId: 'old-request', conversationId: 'old-conversation', prompt: 'test',
|
|
}, new AbortController().signal)
|
|
try {
|
|
expect((await stream.next()).value?.type).toBe('question')
|
|
await controller.replace(next)
|
|
await controller.respondToQuestion('question-old', [])
|
|
expect(previous.respondToQuestion).toHaveBeenCalledWith('question-old', [])
|
|
expect(next.respondToQuestion).not.toHaveBeenCalled()
|
|
release()
|
|
expect((await stream.next()).value?.type).toBe('done')
|
|
} finally {
|
|
release()
|
|
await stream.return()
|
|
await controller.dispose()
|
|
}
|
|
})
|
|
|
|
class TestRuntime implements AgentRuntime {
|
|
readonly dispose = vi.fn(async () => {})
|
|
readonly started: Promise<void>
|
|
private release?: () => void
|
|
private markStarted!: () => void
|
|
|
|
constructor(
|
|
private readonly delayed = false,
|
|
readonly requiresToolApproval = false,
|
|
private readonly invokeToolAuthorization = false,
|
|
readonly supportsToolExecution = true
|
|
) {
|
|
this.started = new Promise((resolve) => {
|
|
this.markStarted = resolve
|
|
})
|
|
}
|
|
|
|
getStatus(): Promise<AgentRuntimeStatus> {
|
|
return Promise.resolve({
|
|
id: 'model',
|
|
label: 'Test',
|
|
available: true,
|
|
supportsToolExecution: this.supportsToolExecution,
|
|
detail: 'Test runtime'
|
|
})
|
|
}
|
|
|
|
async *run(
|
|
request: AgentRequest,
|
|
_signal: AbortSignal,
|
|
authorize?: RuntimeAuthorizer
|
|
): AsyncGenerator<AgentEvent, void, void> {
|
|
this.markStarted()
|
|
if (this.invokeToolAuthorization && authorize) {
|
|
const decision = await authorize({
|
|
scopeKey: 'test:tool',
|
|
title: 'Test tool',
|
|
description: 'Test tool request'
|
|
})
|
|
if (decision === 'deny') {
|
|
throw new Error('tool denied')
|
|
}
|
|
}
|
|
if (this.delayed) {
|
|
await new Promise<void>((resolve) => {
|
|
this.release = resolve
|
|
})
|
|
}
|
|
yield {
|
|
requestId: request.requestId,
|
|
type: 'text',
|
|
delta: 'old runtime event'
|
|
}
|
|
}
|
|
|
|
finish(): void {
|
|
this.release?.()
|
|
}
|
|
|
|
releaseConversation(): Promise<void> {
|
|
return Promise.resolve()
|
|
}
|
|
}
|
|
|
|
class DrainableTestRuntime extends TestRuntime {
|
|
readonly beginDrain = vi.fn(async () => {})
|
|
readonly forceShutdown = vi.fn(async () => {})
|
|
private readonly drained: Promise<void>
|
|
private resolveDrained!: () => void
|
|
|
|
constructor() {
|
|
super(true)
|
|
this.drained = new Promise((resolve) => {
|
|
this.resolveDrained = resolve
|
|
})
|
|
}
|
|
|
|
waitForDrain(): Promise<void> {
|
|
return this.drained
|
|
}
|
|
|
|
releaseConversation(): Promise<void> {
|
|
this.resolveDrained()
|
|
return Promise.resolve()
|
|
}
|
|
}
|
|
|
|
class DetachableTestRuntime extends DrainableTestRuntime {
|
|
readonly detachForApplicationExit = vi.fn(() => undefined)
|
|
}
|
|
|
|
describe('AgentRuntimeController', () => {
|
|
it('fails retired runtime requests and disposes them after exit', async () => {
|
|
const previous = new TestRuntime(true, true)
|
|
const next = new TestRuntime()
|
|
const observeFailure = vi.fn()
|
|
const controller = new AgentRuntimeController(
|
|
previous,
|
|
undefined,
|
|
observeFailure
|
|
)
|
|
const authorize = vi.fn(async () => 'once' as const)
|
|
const approvedStream = controller.run(
|
|
{
|
|
requestId: '1c608898-ecb7-4081-8174-2b6a52f53b08',
|
|
conversationId: 'conversation-2',
|
|
prompt: 'test',
|
|
},
|
|
new AbortController().signal,
|
|
authorize
|
|
)
|
|
const pendingEvent = approvedStream.next()
|
|
await previous.started
|
|
expect(authorize).not.toHaveBeenCalled()
|
|
|
|
const replacement = controller.replace(next)
|
|
previous.finish()
|
|
|
|
await expect(pendingEvent).rejects.toThrow(
|
|
'Runtime 已切换,当前请求已中断'
|
|
)
|
|
await replacement
|
|
expect(previous.dispose).toHaveBeenCalledOnce()
|
|
await expect(controller.getStatus()).resolves.toMatchObject({
|
|
label: 'Test'
|
|
})
|
|
expect(observeFailure).not.toHaveBeenCalled()
|
|
})
|
|
|
|
it('keeps a retiring runtime alive until its status probe finishes', async () => {
|
|
let finishProbe!: () => void
|
|
const probe = new Promise<void>((resolve) => {
|
|
finishProbe = resolve
|
|
})
|
|
const previous = new TestRuntime()
|
|
previous.getStatus = vi.fn(async () => {
|
|
await probe
|
|
return {
|
|
id: 'opencode' as const,
|
|
label: 'OpenCode',
|
|
available: true,
|
|
supportsToolExecution: true,
|
|
detail: 'Ready'
|
|
}
|
|
})
|
|
const next = new TestRuntime()
|
|
const controller = new AgentRuntimeController(previous)
|
|
|
|
const status = controller.getStatus()
|
|
const replacement = controller.replace(next)
|
|
await Promise.resolve()
|
|
expect(previous.dispose).not.toHaveBeenCalled()
|
|
|
|
finishProbe()
|
|
await expect(status).rejects.toThrow('Runtime 已切换')
|
|
await replacement
|
|
expect(previous.dispose).toHaveBeenCalledOnce()
|
|
await controller.dispose()
|
|
})
|
|
|
|
it('lets a shared local request finish while replacing its workspace facade', async () => {
|
|
const previous = Object.assign(new TestRuntime(true), { sharedProcess: true })
|
|
const controller = new AgentRuntimeController(previous, 1)
|
|
const stream = controller.run({
|
|
requestId: '00000000-0000-4000-8000-000000000071',
|
|
conversationId: 'shared-replacement', prompt: 'continue',
|
|
}, new AbortController().signal)
|
|
const pending = stream.next()
|
|
await previous.started
|
|
await controller.replace(new TestRuntime())
|
|
expect(previous.dispose).not.toHaveBeenCalled()
|
|
previous.finish()
|
|
await expect(pending).resolves.toMatchObject({
|
|
done: false, value: { type: 'text' }
|
|
})
|
|
await stream.next()
|
|
expect(previous.dispose).toHaveBeenCalledOnce()
|
|
await controller.dispose()
|
|
})
|
|
|
|
it('drains remote sessions without interrupting their active prompt', async () => {
|
|
const previous = new DrainableTestRuntime()
|
|
const next = new TestRuntime()
|
|
const controller = new AgentRuntimeController(previous)
|
|
const stream = controller.run(
|
|
{
|
|
requestId: '1c608898-ecb7-4081-8174-2b6a52f53b13',
|
|
conversationId: 'conversation-drain',
|
|
prompt: 'test',
|
|
},
|
|
new AbortController().signal
|
|
)
|
|
const pending = stream.next()
|
|
await previous.started
|
|
|
|
await controller.replace(next)
|
|
expect(previous.beginDrain).toHaveBeenCalledOnce()
|
|
expect(previous.dispose).not.toHaveBeenCalled()
|
|
|
|
previous.finish()
|
|
await expect(pending).resolves.toMatchObject({
|
|
value: { type: 'text' }
|
|
})
|
|
await stream.return()
|
|
expect(previous.dispose).not.toHaveBeenCalled()
|
|
|
|
await controller.releaseConversation('conversation-drain')
|
|
await vi.waitFor(() =>
|
|
expect(previous.dispose).toHaveBeenCalledOnce()
|
|
)
|
|
await controller.dispose()
|
|
})
|
|
|
|
it('clears conversation ownership when a Runtime release fails', async () => {
|
|
const runtime = new TestRuntime()
|
|
runtime.releaseConversation = vi.fn(async () => {
|
|
throw new Error('release failed')
|
|
})
|
|
const controller = new AgentRuntimeController(runtime)
|
|
const stream = controller.run(
|
|
{
|
|
requestId: '1c608898-ecb7-4081-8174-2b6a52f53b16',
|
|
conversationId: 'conversation-release-failure',
|
|
prompt: 'test',
|
|
},
|
|
new AbortController().signal
|
|
)
|
|
await stream.next()
|
|
await stream.return()
|
|
|
|
expect(controller.ownedConversationCount).toBe(1)
|
|
await expect(
|
|
controller.releaseConversation(
|
|
'conversation-release-failure'
|
|
)
|
|
).rejects.toBeInstanceOf(AggregateError)
|
|
expect(controller.ownedConversationCount).toBe(0)
|
|
expect(controller.canRetire).toBe(true)
|
|
await controller.dispose()
|
|
})
|
|
|
|
it('counts a draining generation until disposal actually settles', async () => {
|
|
const previous = new DrainableTestRuntime()
|
|
let finishDisposal!: () => void
|
|
previous.dispose.mockImplementation(
|
|
async () =>
|
|
await new Promise<void>((resolve) => {
|
|
finishDisposal = resolve
|
|
})
|
|
)
|
|
const controller = new AgentRuntimeController(previous)
|
|
|
|
await controller.replace(new TestRuntime())
|
|
await controller.releaseConversation('conversation-disposal')
|
|
await vi.waitFor(() =>
|
|
expect(previous.dispose).toHaveBeenCalledOnce()
|
|
)
|
|
expect(controller.replacementStatus.drainingGenerations).toBe(1)
|
|
|
|
finishDisposal()
|
|
await vi.waitFor(() =>
|
|
expect(
|
|
controller.replacementStatus.drainingGenerations
|
|
).toBe(0)
|
|
)
|
|
await controller.dispose()
|
|
})
|
|
|
|
it('bounds retained draining generations and rejects further replacements', async () => {
|
|
const first = new DrainableTestRuntime()
|
|
const second = new DrainableTestRuntime()
|
|
const third = new DrainableTestRuntime()
|
|
const rejected = new TestRuntime()
|
|
const controller = new AgentRuntimeController(first)
|
|
|
|
await controller.replace(second)
|
|
await controller.replace(third)
|
|
|
|
expect(controller.replacementStatus).toEqual({
|
|
drainingGenerations: MAX_DRAINING_RUNTIME_GENERATIONS,
|
|
failedDrainingGenerations: 0,
|
|
pendingReplacements: 0,
|
|
maximumDrainingGenerations: MAX_DRAINING_RUNTIME_GENERATIONS,
|
|
saturated: true
|
|
})
|
|
const replacement = controller.replace(rejected)
|
|
await expect(replacement).rejects.toBeInstanceOf(
|
|
RuntimeReplacementCapacityError
|
|
)
|
|
await expect(replacement).rejects.toMatchObject({
|
|
code: 'runtime-drain-capacity',
|
|
occupiedGenerations: MAX_DRAINING_RUNTIME_GENERATIONS,
|
|
maximumGenerations: MAX_DRAINING_RUNTIME_GENERATIONS
|
|
})
|
|
expect(rejected.dispose).toHaveBeenCalledOnce()
|
|
expect(first.forceShutdown).not.toHaveBeenCalled()
|
|
expect(second.forceShutdown).not.toHaveBeenCalled()
|
|
|
|
await controller.releaseConversation('conversation-drain')
|
|
await vi.waitFor(() => {
|
|
expect(first.dispose).toHaveBeenCalledOnce()
|
|
expect(second.dispose).toHaveBeenCalledOnce()
|
|
})
|
|
await controller.dispose()
|
|
})
|
|
|
|
it('retains a recoverable generation when drain observation fails', async () => {
|
|
const previous = new DrainableTestRuntime()
|
|
previous.waitForDrain = vi.fn(async () => {
|
|
throw new Error('temporary drain status failure')
|
|
})
|
|
const controller = new AgentRuntimeController(previous, 1)
|
|
|
|
await controller.replace(new TestRuntime())
|
|
await vi.waitFor(() =>
|
|
expect(controller.replacementStatus).toMatchObject({
|
|
drainingGenerations: 1,
|
|
failedDrainingGenerations: 1
|
|
})
|
|
)
|
|
expect(previous.dispose).not.toHaveBeenCalled()
|
|
expect(previous.forceShutdown).not.toHaveBeenCalled()
|
|
|
|
await controller.dispose()
|
|
expect(previous.forceShutdown).toHaveBeenCalledOnce()
|
|
expect(previous.dispose).toHaveBeenCalledOnce()
|
|
})
|
|
|
|
it('uses the configured shutdown grace while replacing a busy runtime', async () => {
|
|
vi.useFakeTimers()
|
|
try {
|
|
const previous = new TestRuntime(true)
|
|
const controller = new AgentRuntimeController(previous, 25)
|
|
const stream = controller.run(
|
|
{
|
|
requestId: '1c608898-ecb7-4081-8174-2b6a52f53b14',
|
|
conversationId: 'conversation-replacement-grace',
|
|
prompt: 'test',
|
|
},
|
|
new AbortController().signal
|
|
)
|
|
const pending = stream.next()
|
|
await previous.started
|
|
|
|
const replacement = controller.replace(new TestRuntime())
|
|
await vi.advanceTimersByTimeAsync(24)
|
|
let replaced = false
|
|
void replacement.then(() => {
|
|
replaced = true
|
|
})
|
|
await Promise.resolve()
|
|
expect(replaced).toBe(false)
|
|
|
|
await vi.advanceTimersByTimeAsync(1)
|
|
await replacement
|
|
expect(replaced).toBe(true)
|
|
|
|
previous.finish()
|
|
await expect(pending).rejects.toThrow('Runtime 已切换')
|
|
await stream.return()
|
|
await controller.dispose()
|
|
} finally {
|
|
vi.useRealTimers()
|
|
}
|
|
})
|
|
|
|
it('clears bounded-wait timers after fast lifecycle operations', async () => {
|
|
vi.useFakeTimers()
|
|
try {
|
|
const controller = new AgentRuntimeController(
|
|
new TestRuntime(),
|
|
25
|
|
)
|
|
await controller.replace(new TestRuntime())
|
|
expect(vi.getTimerCount()).toBe(0)
|
|
|
|
await controller.dispose()
|
|
expect(vi.getTimerCount()).toBe(0)
|
|
} finally {
|
|
vi.useRealTimers()
|
|
}
|
|
})
|
|
|
|
it('forces runtime disposal when active work does not stop during shutdown', async () => {
|
|
const runtime = new TestRuntime(true)
|
|
const controller = new AgentRuntimeController(runtime, 1)
|
|
const stream = controller.run(
|
|
{
|
|
requestId: '1c608898-ecb7-4081-8174-2b6a52f53b12',
|
|
conversationId: 'conversation-shutdown',
|
|
prompt: 'test',
|
|
},
|
|
new AbortController().signal
|
|
)
|
|
const pendingEvent = stream.next()
|
|
await runtime.started
|
|
|
|
await controller.dispose()
|
|
expect(runtime.dispose).toHaveBeenCalledOnce()
|
|
|
|
runtime.finish()
|
|
await expect(pendingEvent).resolves.toMatchObject({
|
|
value: { type: 'text' }
|
|
})
|
|
await stream.return()
|
|
})
|
|
|
|
it('detaches a remote runtime on application exit without draining or disposing it', async () => {
|
|
const runtime = new DetachableTestRuntime()
|
|
const controller = new AgentRuntimeController(runtime, 1)
|
|
const stream = controller.run(
|
|
{
|
|
requestId: '1c608898-ecb7-4081-8174-2b6a52f53b17',
|
|
conversationId: 'conversation-application-exit',
|
|
prompt: 'keep running remotely',
|
|
},
|
|
new AbortController().signal
|
|
)
|
|
const pendingEvent = stream.next()
|
|
await runtime.started
|
|
|
|
await controller.detachForApplicationExit()
|
|
|
|
expect(runtime.detachForApplicationExit).toHaveBeenCalledOnce()
|
|
expect(runtime.beginDrain).not.toHaveBeenCalled()
|
|
expect(runtime.forceShutdown).not.toHaveBeenCalled()
|
|
expect(runtime.dispose).not.toHaveBeenCalled()
|
|
|
|
runtime.finish()
|
|
await expect(pendingEvent).resolves.toMatchObject({
|
|
value: { type: 'text' }
|
|
})
|
|
await stream.return()
|
|
})
|
|
|
|
it('allows tools by default without prompting the user', async () => {
|
|
const runtime = new TestRuntime(false, false, true)
|
|
const controller = new AgentRuntimeController(runtime)
|
|
const authorize = vi.fn(async () => 'once' as const)
|
|
const stream = controller.run(
|
|
{
|
|
requestId: '1c608898-ecb7-4081-8174-2b6a52f53b09',
|
|
conversationId: 'conversation-3',
|
|
prompt: 'test',
|
|
},
|
|
new AbortController().signal
|
|
)
|
|
|
|
await expect(stream.next()).resolves.toMatchObject({ value: { type: 'text' } })
|
|
expect(authorize).not.toHaveBeenCalled()
|
|
})
|
|
|
|
it('does not report cancellation, AbortError, or tool denial', async () => {
|
|
const observeFailure = vi.fn()
|
|
const canceledRuntime = new TestRuntime()
|
|
canceledRuntime.run = async function* (
|
|
_request,
|
|
signal
|
|
): AsyncGenerator<AgentEvent, void, void> {
|
|
yield* []
|
|
signal.throwIfAborted()
|
|
await new Promise<void>((_resolve, reject) => {
|
|
signal.addEventListener(
|
|
'abort',
|
|
() => reject(signal.reason),
|
|
{ once: true }
|
|
)
|
|
})
|
|
}
|
|
const canceledController = new AgentRuntimeController(
|
|
canceledRuntime,
|
|
undefined,
|
|
observeFailure
|
|
)
|
|
const abortController = new AbortController()
|
|
const canceled = canceledController.run(
|
|
{
|
|
requestId: '1c608898-ecb7-4081-8174-2b6a52f53b18',
|
|
conversationId: 'conversation-canceled',
|
|
prompt: 'test',
|
|
},
|
|
abortController.signal
|
|
)
|
|
const pending = canceled.next()
|
|
abortController.abort()
|
|
await expect(pending).rejects.toMatchObject({
|
|
name: 'AbortError'
|
|
})
|
|
await canceledController.dispose()
|
|
|
|
const abortErrorRuntime = new TestRuntime()
|
|
abortErrorRuntime.run = async function* (): AsyncGenerator<
|
|
AgentEvent,
|
|
void,
|
|
void
|
|
> {
|
|
yield* []
|
|
throw new DOMException('aborted', 'AbortError')
|
|
}
|
|
const abortErrorController = new AgentRuntimeController(
|
|
abortErrorRuntime,
|
|
undefined,
|
|
observeFailure
|
|
)
|
|
const aborted = abortErrorController.run(
|
|
{
|
|
requestId: '1c608898-ecb7-4081-8174-2b6a52f53b19',
|
|
conversationId: 'conversation-abort-error',
|
|
prompt: 'test',
|
|
},
|
|
new AbortController().signal
|
|
)
|
|
await expect(aborted.next()).rejects.toMatchObject({
|
|
name: 'AbortError'
|
|
})
|
|
await abortErrorController.dispose()
|
|
|
|
const deniedRuntime = new TestRuntime(false, false, true)
|
|
const deniedController = new AgentRuntimeController(
|
|
deniedRuntime,
|
|
undefined,
|
|
observeFailure
|
|
)
|
|
const denied = deniedController.run(
|
|
{
|
|
requestId: '1c608898-ecb7-4081-8174-2b6a52f53b20',
|
|
conversationId: 'conversation-tool-denied',
|
|
prompt: 'test',
|
|
},
|
|
new AbortController().signal,
|
|
async () => 'deny'
|
|
)
|
|
await expect(denied.next()).rejects.toThrow('tool denied')
|
|
await deniedController.dispose()
|
|
|
|
expect(observeFailure).not.toHaveBeenCalled()
|
|
})
|
|
|
|
it('reports genuine Runtime run failures', async () => {
|
|
const runtime = new TestRuntime()
|
|
const failure = new Error('provider failed')
|
|
runtime.run = async function* (): AsyncGenerator<
|
|
AgentEvent,
|
|
void,
|
|
void
|
|
> {
|
|
yield* []
|
|
throw failure
|
|
}
|
|
const observeFailure = vi.fn()
|
|
const controller = new AgentRuntimeController(
|
|
runtime,
|
|
undefined,
|
|
observeFailure
|
|
)
|
|
const stream = controller.run(
|
|
{
|
|
requestId: '1c608898-ecb7-4081-8174-2b6a52f53b21',
|
|
conversationId: 'conversation-run-failed',
|
|
prompt: 'test',
|
|
},
|
|
new AbortController().signal
|
|
)
|
|
|
|
await expect(stream.next()).rejects.toBe(failure)
|
|
expect(observeFailure).toHaveBeenCalledWith({
|
|
component: 'runtime',
|
|
stage: 'run',
|
|
code: 'runtime.run.failed',
|
|
error: failure
|
|
})
|
|
await controller.dispose()
|
|
})
|
|
|
|
it('forwards per-tool authorization without adding a whole-run gate', async () => {
|
|
const runtime = new TestRuntime(false, false, true)
|
|
const controller = new AgentRuntimeController(runtime)
|
|
const authorize = vi.fn(async () => 'session' as const)
|
|
const stream = controller.run(
|
|
{
|
|
requestId: '1c608898-ecb7-4081-8174-2b6a52f53b10',
|
|
conversationId: 'conversation-4',
|
|
prompt: 'test',
|
|
},
|
|
new AbortController().signal,
|
|
authorize
|
|
)
|
|
|
|
await expect(stream.next()).resolves.toMatchObject({
|
|
value: { type: 'text' }
|
|
})
|
|
expect(authorize).toHaveBeenCalledOnce()
|
|
expect(authorize).toHaveBeenCalledWith(
|
|
expect.objectContaining({ scopeKey: 'test:tool' }),
|
|
undefined
|
|
)
|
|
})
|
|
|
|
it('allows text requests when the runtime cannot execute tools', async () => {
|
|
const runtime = new TestRuntime(false, false, false, false)
|
|
const controller = new AgentRuntimeController(runtime)
|
|
const stream = controller.run(
|
|
{
|
|
requestId: '1c608898-ecb7-4081-8174-2b6a52f53b11',
|
|
conversationId: 'conversation-5',
|
|
prompt: 'test',
|
|
},
|
|
new AbortController().signal
|
|
)
|
|
|
|
await expect(stream.next()).resolves.toMatchObject({ value: { type: 'text' } })
|
|
})
|
|
|
|
it('reports Runtime boundary failures without request content', async () => {
|
|
const runtime = new TestRuntime()
|
|
const failure = new Error('provider raw response: secret prompt')
|
|
runtime.getStatus = vi.fn(async () => {
|
|
throw failure
|
|
})
|
|
const observeFailure = vi.fn()
|
|
const controller = new AgentRuntimeController(
|
|
runtime,
|
|
undefined,
|
|
observeFailure
|
|
)
|
|
|
|
await expect(controller.getStatus()).rejects.toBe(failure)
|
|
expect(observeFailure).toHaveBeenCalledWith({
|
|
component: 'runtime',
|
|
stage: 'status',
|
|
code: 'runtime.operation.failed',
|
|
error: failure
|
|
})
|
|
})
|
|
})
|