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:
@@ -27,6 +27,8 @@ import type { JsonRpcTransportPeer } from './transport.ts'
|
||||
export interface InitializeParams {
|
||||
/** Working directory recorded on every SDK-created session's header. */
|
||||
cwd: string
|
||||
/** Provider route every SDK-created agent runs on. */
|
||||
provider: string
|
||||
/** Model name every SDK-created agent runs on (see {@link HarnessSdkServer.initialize} for adapter fallback). */
|
||||
model: string
|
||||
}
|
||||
@@ -85,6 +87,7 @@ function isLocalChild(ctx: Context, id: SessionId, parent: Agent): boolean {
|
||||
*/
|
||||
export class HarnessSdkServer {
|
||||
private cwd = process.cwd()
|
||||
private provider = 'deepseek'
|
||||
private model = 'deepseek'
|
||||
private llmFiber: { dispose(): Promise<void> } | undefined
|
||||
private readonly sessions = new Map<string, SessionRecord>()
|
||||
@@ -156,18 +159,18 @@ export class HarnessSdkServer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle `initialize`: record the SDK deployment facts (cwd, model) and, when
|
||||
* no registered adapter serves `params.model`, mount the DeepSeek adapter for
|
||||
* it (credentials from `$DEEPSEEK_API_KEY`/`$DEEPSEEK_BASE_URL`) — a config
|
||||
* that already registered an adapter for the model wins.
|
||||
* Record cwd and provider/model, mounting the DeepSeek adapter only when the
|
||||
* `deepseek` provider route has no configured owner.
|
||||
* @param params - the SDK handshake parameters.
|
||||
* @returns the server identity for the handshake.
|
||||
*/
|
||||
async initialize(params: InitializeParams): Promise<InitializeResult> {
|
||||
this.cwd = resolve(params.cwd)
|
||||
this.provider = params.provider
|
||||
this.model = params.model
|
||||
if (!this.llmFiber && !this.hasAdapterFor(this.model)) {
|
||||
this.llmFiber = await this.ctx.plugin(LlmDeepSeek, { models: [this.model] })
|
||||
if (!this.hasAdapterFor(this.provider)) {
|
||||
if (this.provider !== 'deepseek') throw new Error(`no adapter registered for provider "${this.provider}"`)
|
||||
this.llmFiber = await this.ctx.plugin(LlmDeepSeek, {})
|
||||
}
|
||||
return { serverInfo: { name: 'deepseek-harness-sdk-runtime', version: '0.0.1' } }
|
||||
}
|
||||
@@ -281,7 +284,7 @@ export class HarnessSdkServer {
|
||||
const handle = await this.ctx.agents.create({
|
||||
sessionId: SessionId(sessionId),
|
||||
meta: { cwd: this.cwd },
|
||||
agentOptions: { model: this.model },
|
||||
agentOptions: { provider: this.provider, model: this.model },
|
||||
})
|
||||
const rec: SessionRecord = { handle, lastTurnEnd: undefined, activePrompt: false }
|
||||
this.sessions.set(sessionId, rec)
|
||||
@@ -293,7 +296,7 @@ export class HarnessSdkServer {
|
||||
return reason.kind === 'completed' ? 'ok' : 'error'
|
||||
}
|
||||
|
||||
private hasAdapterFor(model: string): boolean {
|
||||
return this.ctx.get('llm')?.models().includes(model) ?? false
|
||||
private hasAdapterFor(provider: string): boolean {
|
||||
return this.ctx.get('llm')?.listProviders().some(entry => entry.id === provider) ?? false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user