Files
deepseek-harness/packages/bundle/sdk-app/src/index.ts
T
Tianyi Cui a16822944b feat(profiles): add the SDK application bundle
Introduce @deepseek-ai/dsh-sdk-app as the thin application layer for the built-in sdk profile. The bundle contributes the JSON-RPC server and startup-only profile metadata, while dsh-base continues to own the shared agent, provider, persistence, and tool composition.

Publish ctx.appReady from the launcher only after the Loader tree and launcher-owned setup succeed. The stdio lifetime binding leaves stdin unread until the protocol transport claims it and defers EOF exit 0 until readiness commits, so early protocol frames remain buffered and a racing startup failure remains the nonzero process outcome. Fiber disposal cancels both pending lifecycle listeners.

Register the bundle in the CLI resolver closure, generated configuration catalog, workspace graph, and built-bin smoke. Startup tests prove that base plus sdk-app exposes the SDK server without taking ownership of shared runtime plugins; focused and built-bin regressions cover early input, EOF readiness, and startup-error precedence.
2026-08-23 10:59:00 +08:00

49 lines
1.6 KiB
TypeScript

/**
* The SDK profile's command-line and stdin-lifetime provider. A successful
* parse publishes {@link SDK_APP_STARTUP_SERVICE}; the JSON-RPC server waits
* for that service, so help starts no transport.
* @module @deepseek-ai/dsh-sdk-app
*/
import { Command } from 'commander'
import type { Context } from '@deepseek-ai/cordis'
import { exitOnStdinEnd, parseCmdline } from '@deepseek-ai/dsh-cmdline'
/** Stable Cordis plugin name. */
export const name = 'sdk-app-startup'
/** Launcher service required before this app can parse its invocation. */
export const inject = ['cmdlineArgs']
/** Service the JSON-RPC server row waits for before claiming stdio. */
export const SDK_APP_STARTUP_SERVICE = 'sdkAppStartup'
/**
* Build this app's zero-option command and help.
* @returns a fresh program for one invocation.
*/
function sdkCommand(): Command {
return new Command()
.name('dsh --profile sdk')
.description('Serve DeepSeek Harness SDK clients over stdio JSON-RPC.')
.helpOption('-h, --help', 'show this help')
.addHelpText('after', `
Example:
dsh --profile sdk serve one SDK runtime until its client disconnects
`)
}
/**
* Accept an SDK profile invocation, publish readiness, and bind EOF to the
* launcher's bounded shutdown.
* @param ctx - plugin context carrying command-line and exit launcher values.
*/
export function apply(ctx: Context): void {
const program = sdkCommand()
program.action(() => {
exitOnStdinEnd(ctx, 'sdk-app.stdin')
ctx.provide(SDK_APP_STARTUP_SERVICE, { accepted: true })
})
parseCmdline(ctx, program)
}