mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-08 04:01:59 +00:00
refactor(sdk): relocate JSON-RPC example and runtime without edits
Move examples/jsonrpc-agent to examples/python-sdk-agent and packages/examples/jsonrpc-demo to packages/sdk/python-runtime while preserving every file byte-for-byte. The directory placement now reflects the example's Python-distribution role and the private runtime carrier's SDK ownership. This commit deliberately keeps the old package names, commands, configuration, and snapshots inside their new directories. All 42 files are 100% renames; API/profile migration and naming changes follow separately so reviewers do not have to disentangle behavior from filesystem movement.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Generic JSON-RPC agent bin. External configurations own their bare plugin
|
||||
* packages; the packaged runtime uses `packaged-bin.ts` instead.
|
||||
*
|
||||
* @module @deepseek-ai/dsh-sdk-jsonrpc-demo/bin
|
||||
*/
|
||||
|
||||
import { runJsonrpcAgent } from './runner.ts'
|
||||
|
||||
await runJsonrpcAgent()
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Bin-only app package: its generic and packaged entries discover an external
|
||||
* `cordis.yml` and own process exit. This module exports no composition plugin;
|
||||
* the config chooses whether to load the
|
||||
* {@link @deepseek-ai/dsh-sdk-jsonrpc-server} serving plugin.
|
||||
*
|
||||
* @module @deepseek-ai/dsh-sdk-jsonrpc-demo
|
||||
*/
|
||||
|
||||
export {}
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Package-owned invariant companion for `@deepseek-ai/dsh-sdk-jsonrpc-demo`.
|
||||
* @module @deepseek-ai/dsh-sdk-jsonrpc-demo/invariant
|
||||
*/
|
||||
|
||||
/* jscpd:ignore-start */
|
||||
import type { Context } from '@deepseek-ai/cordis'
|
||||
import type { InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
|
||||
const PACKAGE_NAME = '@deepseek-ai/dsh-sdk-jsonrpc-demo'
|
||||
|
||||
/** Cordis companion plugin name. */
|
||||
export const name = 'sdk-jsonrpc-demo-invariant'
|
||||
/** Service required before the companion can reserve package ownership. */
|
||||
export const inject = ['invariants']
|
||||
|
||||
/**
|
||||
* No runtime invariant: this composition package owns no independent event stream or mutable data;
|
||||
* Loader and built-entry tests cover its wiring.
|
||||
*/
|
||||
const install: InvariantInstaller = () => {}
|
||||
|
||||
/**
|
||||
* Register this package's invariant companion.
|
||||
* @param ctx - Cordis context carrying the invariant service.
|
||||
* @returns the installed registration's disposer after setup succeeds.
|
||||
*/
|
||||
export const apply = (ctx: Context): Promise<() => void> =>
|
||||
Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install))
|
||||
/* jscpd:ignore-end */
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Closed-runtime JSON-RPC agent bin. Bare plugins resolve from the installed
|
||||
* runtime closure while relative plugins remain configuration-relative.
|
||||
*
|
||||
* @module @deepseek-ai/dsh-sdk-jsonrpc-demo/packaged-bin
|
||||
*/
|
||||
|
||||
import { runJsonrpcAgent } from './runner.ts'
|
||||
|
||||
/* v8 ignore next -- exercised through the built Python runtime carriers */
|
||||
await runJsonrpcAgent(import.meta.url)
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Shared process lifecycle for the generic and closed-runtime JSON-RPC bins.
|
||||
*
|
||||
* @module @deepseek-ai/dsh-sdk-jsonrpc-demo/runner
|
||||
*/
|
||||
|
||||
import { existsSync } from 'node:fs'
|
||||
import { boot, installFailLoud, loadEnv, resolveConfigPath } from '@deepseek-ai/dsh-app-boot'
|
||||
|
||||
/* v8 ignore start -- composition over tested app-boot/jsonrpc and executable acceptance paths */
|
||||
const NAME = 'dsh-jsonrpc-agent'
|
||||
|
||||
/**
|
||||
* Boot the explicitly selected external configuration and own process exit.
|
||||
* @param bareModuleBaseUrl - optional installed-runtime base for bare plugins;
|
||||
* omit it when the configuration project owns its plugin packages.
|
||||
* @returns after process handlers are installed; process lifetime then belongs
|
||||
* to stdin and signal events.
|
||||
*/
|
||||
export async function runJsonrpcAgent(bareModuleBaseUrl?: string): Promise<void> {
|
||||
installFailLoud(NAME)
|
||||
loadEnv(NAME)
|
||||
|
||||
// Env wins over argv; empty values are absent. External config defines the deployment.
|
||||
const fromEnv = process.env['DSH_CORDIS_CONFIG']
|
||||
const fromArgv = process.argv[2]
|
||||
const requested = fromEnv !== undefined && fromEnv !== ''
|
||||
? fromEnv
|
||||
: fromArgv !== undefined && fromArgv !== '' ? fromArgv : undefined
|
||||
const configPath = requested === undefined ? undefined : resolveConfigPath(requested, undefined)
|
||||
if (configPath === undefined || !existsSync(configPath)) {
|
||||
process.stderr.write(
|
||||
`usage: ${NAME} <path/to/cordis.yml> (or set DSH_CORDIS_CONFIG=<path>, which wins); the config is required — there is no built-in fallback\n`,
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const ctx = await boot(NAME, configPath, undefined, undefined, bareModuleBaseUrl)
|
||||
let exiting = false
|
||||
|
||||
async function disposeAndExit(code: number): Promise<void> {
|
||||
if (exiting) return
|
||||
exiting = true
|
||||
try {
|
||||
await ctx.fiber.dispose()
|
||||
} finally {
|
||||
process.exit(code)
|
||||
}
|
||||
}
|
||||
|
||||
process.stdin.on('end', () => { void disposeAndExit(0) })
|
||||
process.on('SIGTERM', () => { void disposeAndExit(0) })
|
||||
process.on('SIGINT', () => { void disposeAndExit(130) })
|
||||
}
|
||||
/* v8 ignore stop */
|
||||
Reference in New Issue
Block a user