@hydraharness/harness-sdk-jsonrpc-demo 0.1.1-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeepSeek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # @hydraharness/harness-sdk-jsonrpc-demo
2
+
3
+ Bin-only app that boots an external `cordis.yml`; its [`jsonrpc`](../../sdk/server/README.md) entry serves SDK clients over newline-delimited stdio. The config composes the spine, backends, and serving plugin. The published `hydra-jsonrpc-agent` bin resolves bare plugins from the configuration project. The Python SDK's `hydra-jsonrpc-agent-pkg` [single-executable runtime](../../../.agents/notes/implemented/architecture/2026-07-10-single-file-executable-sdk-runtime-distribution.md) uses `lib/packaged-bin.js` instead: packaged bare plugins resolve from its closed runtime tree, while relative plugins remain configuration-relative.
4
+
5
+ ## Config discovery
6
+
7
+ The first non-empty channel wins: `$HYDRA_CORDIS_CONFIG`, then positional `argv[2]`. If neither names an existing file, the bin prints one-line usage to stderr and exits 1; there is no working-directory or built-in fallback. [`@hydraharness/harness-app-boot`](../../boot/app-boot/README.md) makes plugin load failures fatal. This protocol does not use `HYDRA_SNAPSHOT`.
8
+
9
+ A config without `@hydraharness/harness-sdk-jsonrpc-server` is valid and serves nothing; the bin does not designate a server plugin.
10
+
11
+ ## Exit lifecycle
12
+
13
+ stdin EOF and `SIGTERM` dispose the root to quiescence and exit 0; `SIGINT` exits 130 after the same disposal. EOF may cut off an in-flight turn as documented in the [distribution Agent Note](../../../.agents/notes/implemented/architecture/2026-07-10-single-file-executable-sdk-runtime-distribution.md). The `jsonrpc` plugin owns response-before-exit protocol shutdown; both paths are idempotent and safe to race.
14
+
15
+ ## stdout is the protocol
16
+
17
+ stdout carries only JSON-RPC frames. The bin and boot guards diagnose on stderr, and the config must omit stdout loggers.
18
+
19
+ ## Model Experience
20
+
21
+ Indirectly, through the plugins loaded from the external `cordis.yml`, which own every model-bound prompt, schema, message, and result; this bin adds none of its own.
22
+
23
+ #### KV Cache effect
24
+
25
+ No direct invalidation; the named consumer owns any request-prefix changes.
26
+
27
+ ## Known Limitations and Deferred Work
28
+
29
+ - **The bin cannot prove that the config serves JSON-RPC** — a valid config with no `@hydraharness/harness-sdk-jsonrpc-server` entry boots successfully and serves nothing.
30
+ - **No built-in or default config exists** — every launch must provide `HYDRA_CORDIS_CONFIG` or a positional path, and deployment owns the complete plugin tree and stdout discipline.
31
+ - **stdin EOF cuts off in-flight work** — client disappearance disposes the root immediately; callers that need orderly completion use the protocol-level `shutdown` request.
package/lib/bin.js ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync } from "node:fs";
3
+ import { boot, installFailLoud, loadEnv, resolveConfigPath } from "@hydraharness/harness-app-boot";
4
+ //#region lib/types/runner.js
5
+ /**
6
+ * Shared process lifecycle for the generic and closed-runtime JSON-RPC bins.
7
+ *
8
+ * @module @hydraharness/harness-sdk-jsonrpc-demo/runner
9
+ */
10
+ /* v8 ignore start -- composition over tested app-boot/jsonrpc and executable acceptance paths */
11
+ const NAME = "hydra-jsonrpc-agent";
12
+ /**
13
+ * Boot the explicitly selected external configuration and own process exit.
14
+ * @param bareModuleBaseUrl - optional installed-runtime base for bare plugins;
15
+ * omit it when the configuration project owns its plugin packages.
16
+ * @returns after process handlers are installed; process lifetime then belongs
17
+ * to stdin and signal events.
18
+ */
19
+ async function runJsonrpcAgent(bareModuleBaseUrl) {
20
+ installFailLoud(NAME);
21
+ loadEnv(NAME);
22
+ const fromEnv = process.env["HYDRA_CORDIS_CONFIG"];
23
+ const fromArgv = process.argv[2];
24
+ const requested = fromEnv !== void 0 && fromEnv !== "" ? fromEnv : fromArgv !== void 0 && fromArgv !== "" ? fromArgv : void 0;
25
+ const configPath = requested === void 0 ? void 0 : resolveConfigPath(requested, void 0);
26
+ if (configPath === void 0 || !existsSync(configPath)) {
27
+ process.stderr.write(`usage: ${NAME} <path/to/cordis.yml> (or set HYDRA_CORDIS_CONFIG=<path>, which wins); the config is required — there is no built-in fallback\n`);
28
+ process.exit(1);
29
+ }
30
+ const ctx = await boot(NAME, configPath, void 0, void 0, bareModuleBaseUrl);
31
+ let exiting = false;
32
+ async function disposeAndExit(code) {
33
+ if (exiting) return;
34
+ exiting = true;
35
+ try {
36
+ await ctx.fiber.dispose();
37
+ } finally {
38
+ process.exit(code);
39
+ }
40
+ }
41
+ process.stdin.on("end", () => {
42
+ disposeAndExit(0);
43
+ });
44
+ process.on("SIGTERM", () => {
45
+ disposeAndExit(0);
46
+ });
47
+ process.on("SIGINT", () => {
48
+ disposeAndExit(130);
49
+ });
50
+ }
51
+ /* v8 ignore stop */
52
+ //#endregion
53
+ //#region lib/types/bin.js
54
+ /**
55
+ * Generic JSON-RPC agent bin. External configurations own their bare plugin
56
+ * packages; the packaged runtime uses `packaged-bin.ts` instead.
57
+ *
58
+ * @module @hydraharness/harness-sdk-jsonrpc-demo/bin
59
+ */
60
+ await runJsonrpcAgent();
61
+ //#endregion
62
+ export {};
package/lib/index.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ //#region lib/types/invariant.js
2
+ /**
3
+ * Package-owned invariant companion for `@hydraharness/harness-sdk-jsonrpc-demo`.
4
+ * @module @hydraharness/harness-sdk-jsonrpc-demo/invariant
5
+ */
6
+ const PACKAGE_NAME = "@hydraharness/harness-sdk-jsonrpc-demo";
7
+ /** Cordis companion plugin name. */
8
+ const name = "sdk-jsonrpc-demo-invariant";
9
+ /** Service required before the companion can reserve package ownership. */
10
+ const inject = ["invariants"];
11
+ /**
12
+ * No runtime invariant: this composition package owns no independent event stream or mutable data;
13
+ * Loader and built-entry tests cover its wiring.
14
+ */
15
+ const install = () => {};
16
+ /**
17
+ * Register this package's invariant companion.
18
+ * @param ctx - Cordis context carrying the invariant service.
19
+ * @returns the installed registration's disposer after setup succeeds.
20
+ */
21
+ const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
22
+ //#endregion
23
+ export { apply, inject, name };
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync } from "node:fs";
3
+ import { boot, installFailLoud, loadEnv, resolveConfigPath } from "@hydraharness/harness-app-boot";
4
+ //#region lib/types/runner.js
5
+ /**
6
+ * Shared process lifecycle for the generic and closed-runtime JSON-RPC bins.
7
+ *
8
+ * @module @hydraharness/harness-sdk-jsonrpc-demo/runner
9
+ */
10
+ /* v8 ignore start -- composition over tested app-boot/jsonrpc and executable acceptance paths */
11
+ const NAME = "hydra-jsonrpc-agent";
12
+ /**
13
+ * Boot the explicitly selected external configuration and own process exit.
14
+ * @param bareModuleBaseUrl - optional installed-runtime base for bare plugins;
15
+ * omit it when the configuration project owns its plugin packages.
16
+ * @returns after process handlers are installed; process lifetime then belongs
17
+ * to stdin and signal events.
18
+ */
19
+ async function runJsonrpcAgent(bareModuleBaseUrl) {
20
+ installFailLoud(NAME);
21
+ loadEnv(NAME);
22
+ const fromEnv = process.env["HYDRA_CORDIS_CONFIG"];
23
+ const fromArgv = process.argv[2];
24
+ const requested = fromEnv !== void 0 && fromEnv !== "" ? fromEnv : fromArgv !== void 0 && fromArgv !== "" ? fromArgv : void 0;
25
+ const configPath = requested === void 0 ? void 0 : resolveConfigPath(requested, void 0);
26
+ if (configPath === void 0 || !existsSync(configPath)) {
27
+ process.stderr.write(`usage: ${NAME} <path/to/cordis.yml> (or set HYDRA_CORDIS_CONFIG=<path>, which wins); the config is required — there is no built-in fallback\n`);
28
+ process.exit(1);
29
+ }
30
+ const ctx = await boot(NAME, configPath, void 0, void 0, bareModuleBaseUrl);
31
+ let exiting = false;
32
+ async function disposeAndExit(code) {
33
+ if (exiting) return;
34
+ exiting = true;
35
+ try {
36
+ await ctx.fiber.dispose();
37
+ } finally {
38
+ process.exit(code);
39
+ }
40
+ }
41
+ process.stdin.on("end", () => {
42
+ disposeAndExit(0);
43
+ });
44
+ process.on("SIGTERM", () => {
45
+ disposeAndExit(0);
46
+ });
47
+ process.on("SIGINT", () => {
48
+ disposeAndExit(130);
49
+ });
50
+ }
51
+ /* v8 ignore stop */
52
+ //#endregion
53
+ //#region lib/types/packaged-bin.js
54
+ /**
55
+ * Closed-runtime JSON-RPC agent bin. Bare plugins resolve from the installed
56
+ * runtime closure while relative plugins remain configuration-relative.
57
+ *
58
+ * @module @hydraharness/harness-sdk-jsonrpc-demo/packaged-bin
59
+ */
60
+ /* v8 ignore next -- exercised through the built Python runtime carriers */
61
+ await runJsonrpcAgent(import.meta.url);
62
+ //#endregion
63
+ export {};
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Generic JSON-RPC agent bin. External configurations own their bare plugin
4
+ * packages; the packaged runtime uses `packaged-bin.ts` instead.
5
+ *
6
+ * @module @hydraharness/harness-sdk-jsonrpc-demo/bin
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Bin-only app package: its generic and packaged entries discover an external
3
+ * `cordis.yml` and own process exit. This module exports no composition plugin;
4
+ * the config chooses whether to load the
5
+ * {@link @hydraharness/harness-sdk-jsonrpc-server} serving plugin.
6
+ *
7
+ * @module @hydraharness/harness-sdk-jsonrpc-demo
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Package-owned invariant companion for `@hydraharness/harness-sdk-jsonrpc-demo`.
3
+ * @module @hydraharness/harness-sdk-jsonrpc-demo/invariant
4
+ */
5
+ import type { Context } from '@hydraharness/cordis';
6
+ /** Cordis companion plugin name. */
7
+ export declare const name = "sdk-jsonrpc-demo-invariant";
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export declare const inject: string[];
10
+ /**
11
+ * Register this package's invariant companion.
12
+ * @param ctx - Cordis context carrying the invariant service.
13
+ * @returns the installed registration's disposer after setup succeeds.
14
+ */
15
+ export declare const apply: (ctx: Context) => Promise<() => void>;
16
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Closed-runtime JSON-RPC agent bin. Bare plugins resolve from the installed
4
+ * runtime closure while relative plugins remain configuration-relative.
5
+ *
6
+ * @module @hydraharness/harness-sdk-jsonrpc-demo/packaged-bin
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=packaged-bin.d.ts.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Shared process lifecycle for the generic and closed-runtime JSON-RPC bins.
3
+ *
4
+ * @module @hydraharness/harness-sdk-jsonrpc-demo/runner
5
+ */
6
+ /**
7
+ * Boot the explicitly selected external configuration and own process exit.
8
+ * @param bareModuleBaseUrl - optional installed-runtime base for bare plugins;
9
+ * omit it when the configuration project owns its plugin packages.
10
+ * @returns after process handlers are installed; process lifetime then belongs
11
+ * to stdin and signal events.
12
+ */
13
+ export declare function runJsonrpcAgent(bareModuleBaseUrl?: string): Promise<void>;
14
+ //# sourceMappingURL=runner.d.ts.map
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@hydraharness/harness-sdk-jsonrpc-demo",
3
+ "description": "Bin that boots an external Cordis config for the stdio JSON-RPC SDK runtime",
4
+ "version": "0.1.1-rc.10",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/MaiHongPhong2010/Hydra-Harness.git",
11
+ "directory": "packages/examples/jsonrpc-demo"
12
+ },
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "types": "lib/types/index.d.ts",
16
+ "bin": {
17
+ "hydra-jsonrpc-agent": "lib/bin.js"
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "types": "./lib/types/index.d.ts",
22
+ "default": "./lib/index.js"
23
+ },
24
+ "./invariant": {
25
+ "types": "./lib/types/invariant.d.ts",
26
+ "default": "./lib/invariant.js"
27
+ },
28
+ "./bin": {
29
+ "types": "./lib/types/bin.d.ts",
30
+ "default": "./lib/bin.js"
31
+ },
32
+ "./packaged-bin": {
33
+ "types": "./lib/types/packaged-bin.d.ts",
34
+ "default": "./lib/packaged-bin.js"
35
+ },
36
+ "./src/*": "./src/*",
37
+ "./package.json": "./package.json"
38
+ },
39
+ "files": [
40
+ "lib/index.js",
41
+ "lib/invariant.js",
42
+ "lib/bin.js",
43
+ "lib/packaged-bin.js",
44
+ "lib/types/**/*.d.ts"
45
+ ],
46
+ "license": "MIT",
47
+ "dependencies": {
48
+ "@hydraharness/harness-app-boot": "^0.1.1-rc.10"
49
+ },
50
+ "peerDependencies": {
51
+ "@hydraharness/harness-invariants": "^0.1.1-rc.10",
52
+ "@hydraharness/cordis": "^4.0.2"
53
+ },
54
+ "devDependencies": {
55
+ "@hydraharness/harness-invariants": "^0.1.1-rc.10",
56
+ "@hydraharness/cordis": "^4.0.2"
57
+ }
58
+ }