Merge branch 'codex/simp-unify-agent-session-id' into codex/simp-ui-identity-residue
# Conflicts: # AGENTS.md # docs/config-catalog.md # docs/event-producer-consumer.md # examples/acp-agent/tests/snapshots/advanced-toolchain/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/both-mode-turn/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/cancel/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/code-mode-turn/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/config-options/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/error-finish/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/escalation-approved/session.jsonl # examples/acp-agent/tests/snapshots/escalation-approved/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/escalation-rejected/session.jsonl # examples/acp-agent/tests/snapshots/escalation-rejected/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/fs-edit/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/fs-policy-reject/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/fs-read-window/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/fs-read/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/fs-terminal-card/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/fs-write-overwrite/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/fs-write/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/handshake/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/hook-cc-posttool-block/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/hook-cc-posttool-context/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/hook-cc-pretool-ask/session.jsonl # examples/acp-agent/tests/snapshots/hook-cc-pretool-ask/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/hook-cc-pretool-deny/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/hook-cc-promptsubmit-block/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/hook-cc-promptsubmit-context/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/hook-cc-stop-continue/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/hook-codex-posttool-block/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/hook-codex-posttool-context/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/hook-codex-pretool-block/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/hook-codex-promptsubmit-block/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/hook-codex-promptsubmit-context/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/hook-codex-stop-continue/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/multi-turn/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/permission-switching/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/repeat-tool-guard/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/skill-load/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/subagent-fork/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/subagent-mixed/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/subagent-multi/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/subagent-spawn/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/text-turn/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/todo-plan/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/tool-call-turn/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/workflow-run/stdout.golden.jsonl # examples/acp-agent/tests/snapshots/workspace-edit/stdout.golden.jsonl # packages/ui/acp/README.md # packages/ui/acp/src/index.ts # packages/ui/jsonrpc/README.md # packages/ui/jsonrpc/src/server.ts
This commit is contained in:
@@ -59,7 +59,7 @@ async function mockCompletionServer(): Promise<{ url: string; requests: unknown[
|
||||
|
||||
async function makeHarness(storageDir: string) {
|
||||
const ctx = new Context()
|
||||
await ctx.plugin(agentCore)
|
||||
await ctx.plugin(agentCore, { workspaceContext: false })
|
||||
await ctx.plugin(SubagentService)
|
||||
await ctx.plugin(SessionPersistenceJsonl, { root: storageDir })
|
||||
await new Promise(resolve => setTimeout(resolve, 50))
|
||||
@@ -118,6 +118,7 @@ describe('HarnessSdkServer', () => {
|
||||
|
||||
const init = await server.handleRequest('initialize', {
|
||||
cwd: storageDir,
|
||||
provider: 'deepseek',
|
||||
model: 'dsagent-model',
|
||||
}) as { serverInfo: { name: string } }
|
||||
expect(init.serverInfo.name).toBe('deepseek-harness-sdk-runtime')
|
||||
@@ -148,7 +149,7 @@ describe('HarnessSdkServer', () => {
|
||||
const orphanHandle = await ctx.agents.create({
|
||||
sessionId: SessionId('orphan-session'),
|
||||
meta: { cwd: storageDir },
|
||||
agentOptions: { model: 'dsagent-model' },
|
||||
agentOptions: { provider: 'deepseek', model: 'dsagent-model' },
|
||||
})
|
||||
orphanHandle.agent.send([{ type: 'text', text: 'outside the sdk session map' }])
|
||||
await orphanHandle.agent.whenIdle()
|
||||
@@ -251,7 +252,7 @@ describe('HarnessSdkServer', () => {
|
||||
try {
|
||||
const server = new HarnessSdkServer(ctx, new FakeTransport())
|
||||
|
||||
await server.initialize({ cwd: storageDir, model: 'plain-model' })
|
||||
await server.initialize({ cwd: storageDir, provider: 'deepseek', model: 'plain-model' })
|
||||
await server.prompt({
|
||||
sessionId: 'plain',
|
||||
contentBlocks: [{ type: 'text', text: 'hello' }],
|
||||
@@ -275,14 +276,14 @@ describe('HarnessSdkServer', () => {
|
||||
const parentHandle = await ctx.agents.create({
|
||||
sessionId: SessionId('main'),
|
||||
meta: { cwd: storageDir },
|
||||
agentOptions: { model: 'deepseek' },
|
||||
agentOptions: { provider: 'deepseek', model: 'deepseek' },
|
||||
})
|
||||
// A custom in-process provider may own its child at the provider/root
|
||||
// scope while preserving durable parent lineage.
|
||||
const handle = await ctx.agents.create({
|
||||
sessionId: SessionId('child-session'),
|
||||
meta: { cwd: storageDir, parentSession: SessionId('main') },
|
||||
agentOptions: { model: 'deepseek' },
|
||||
agentOptions: { provider: 'deepseek', model: 'deepseek' },
|
||||
})
|
||||
expect(ctx.agents.roots()).toContain(handle.agent)
|
||||
const parentlessHandle = await parentHandle.agent.ctx.agents.create({
|
||||
@@ -521,17 +522,17 @@ describe('HarnessSdkServer', () => {
|
||||
parentHandle = await ctx.agents.create({
|
||||
sessionId: SessionId('fallback-parent'),
|
||||
meta: { cwd: storageDir },
|
||||
agentOptions: { model: 'deepseek' },
|
||||
agentOptions: { provider: 'deepseek', model: 'deepseek' },
|
||||
})
|
||||
handle = await parentHandle.agent.ctx.agents.create({
|
||||
sessionId: SessionId('fallback-child-session'),
|
||||
meta: { cwd: storageDir, parentSession: SessionId('fallback-parent') },
|
||||
agentOptions: { model: 'deepseek' },
|
||||
agentOptions: { provider: 'deepseek', model: 'deepseek' },
|
||||
})
|
||||
failedHandle = await parentHandle.agent.ctx.agents.create({
|
||||
sessionId: SessionId('failed-child-session'),
|
||||
meta: { cwd: storageDir },
|
||||
agentOptions: { model: 'deepseek' },
|
||||
agentOptions: { provider: 'deepseek', model: 'deepseek' },
|
||||
})
|
||||
const missedStartResult = Promise.withResolvers<SubagentResult>()
|
||||
const disposeMissedStartProvider = ctx.subagents.registerProvider({
|
||||
@@ -616,20 +617,20 @@ describe('HarnessSdkServer', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('does not re-register an LLM adapter that already exists', async () => {
|
||||
it('does not re-register an LLM adapter whose provider already has an owner', async () => {
|
||||
const storageDir = await mkdtemp(join(tmpdir(), 'dsh-jsonrpc-existing-llm-'))
|
||||
const ctx = await makeHarness(storageDir)
|
||||
vi.stubEnv('DEEPSEEK_API_KEY', 'test-key')
|
||||
await ctx.plugin(LlmDeepSeek, { models: ['preinstalled-model'] })
|
||||
await ctx.plugin(LlmDeepSeek)
|
||||
try {
|
||||
const server = new HarnessSdkServer(ctx, new FakeTransport())
|
||||
const inspect = server as unknown as { hasAdapterFor(model: string): boolean }
|
||||
const inspect = server as unknown as { hasAdapterFor(provider: string): boolean }
|
||||
|
||||
expect(inspect.hasAdapterFor('preinstalled-model')).toBe(true)
|
||||
expect(inspect.hasAdapterFor('missing-model')).toBe(false)
|
||||
await server.initialize({ cwd: storageDir, model: 'preinstalled-model' })
|
||||
expect(inspect.hasAdapterFor('deepseek')).toBe(true)
|
||||
expect(inspect.hasAdapterFor('missing-provider')).toBe(false)
|
||||
await server.initialize({ cwd: storageDir, provider: 'deepseek', model: 'preinstalled-model' })
|
||||
|
||||
expect(ctx.get('llm')?.models().filter(model => model === 'preinstalled-model')).toEqual(['preinstalled-model'])
|
||||
expect(ctx.get('llm')?.listProviders().filter(provider => provider.id === 'deepseek')).toEqual([{ id: 'deepseek', name: 'DeepSeek' }])
|
||||
await server.shutdown()
|
||||
} finally {
|
||||
await ctx.fiber.dispose()
|
||||
@@ -637,17 +638,18 @@ describe('HarnessSdkServer', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('registers a missing model when an LLM service already exists', async () => {
|
||||
it('rejects a missing non-DeepSeek provider when an LLM service already exists', async () => {
|
||||
const storageDir = await mkdtemp(join(tmpdir(), 'dsh-jsonrpc-new-llm-'))
|
||||
const ctx = await makeHarness(storageDir)
|
||||
vi.stubEnv('DEEPSEEK_API_KEY', 'test-key')
|
||||
await ctx.plugin(LlmDeepSeek, { models: ['other-model'] })
|
||||
await ctx.plugin(LlmDeepSeek)
|
||||
try {
|
||||
const server = new HarnessSdkServer(ctx, new FakeTransport())
|
||||
|
||||
await server.initialize({ cwd: storageDir, model: 'new-model' })
|
||||
await expect(server.initialize({ cwd: storageDir, provider: 'private', model: 'new-model' }))
|
||||
.rejects.toThrow('no adapter registered for provider "private"')
|
||||
|
||||
expect(ctx.get('llm')?.models()).toEqual(expect.arrayContaining(['other-model', 'new-model']))
|
||||
expect(ctx.get('llm')?.listProviders()).toEqual([{ id: 'deepseek', name: 'DeepSeek' }])
|
||||
await server.shutdown()
|
||||
} finally {
|
||||
await ctx.fiber.dispose()
|
||||
@@ -748,15 +750,15 @@ describe('HarnessSdkServer', () => {
|
||||
const ctx = {
|
||||
on: vi.fn(() => () => undefined),
|
||||
agents: { create, get: () => undefined },
|
||||
get: () => ({ models: () => ['model'] }),
|
||||
get: () => ({ listProviders: () => [{ id: 'mock', name: 'Mock' }] }),
|
||||
} as unknown as Context
|
||||
const server = new HarnessSdkServer(ctx, new FakeTransport()) as unknown as {
|
||||
initialize(params: { cwd: string; model: string }): Promise<unknown>
|
||||
initialize(params: { cwd: string; provider: string; model: string }): Promise<unknown>
|
||||
getOrCreateSession(sessionId: string): Promise<unknown>
|
||||
shutdown(): Promise<Record<string, never>>
|
||||
}
|
||||
|
||||
await server.initialize({ cwd: '.', model: 'model' })
|
||||
await server.initialize({ cwd: '.', provider: 'mock', model: 'model' })
|
||||
await server.getOrCreateSession('relative')
|
||||
|
||||
expect(create).toHaveBeenCalledWith(expect.objectContaining({ meta: { cwd: process.cwd() } }))
|
||||
|
||||
Reference in New Issue
Block a user