@easynet-run/node 0.27.14 → 0.39.29
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/README.md +39 -1
- package/native/dendrite-bridge-manifest.json +5 -4
- package/native/dendrite-bridge.json +1 -1
- package/native/include/axon_dendrite_bridge.h +18 -4
- package/native/libaxon_dendrite_bridge.so +0 -0
- package/package.json +9 -5
- package/runtime/easynet-runtime-rs-0.39.29-x86_64-unknown-linux-gnu.tar.gz +0 -0
- package/runtime/runtime-bridge-manifest.json +4 -4
- package/runtime/runtime-bridge.json +3 -3
- package/src/ability_lifecycle.d.ts +12 -1
- package/src/ability_lifecycle.js +117 -31
- package/src/capability_request.js +3 -1
- package/src/dendrite_bridge/bridge.d.ts +10 -2
- package/src/dendrite_bridge/bridge.js +75 -14
- package/src/dendrite_bridge/ffi.d.ts +4 -0
- package/src/dendrite_bridge/ffi.js +194 -18
- package/src/dendrite_bridge/types.d.ts +4 -0
- package/src/errors.js +9 -3
- package/src/index.d.ts +3 -3
- package/src/index.js +9 -10
- package/src/mcp/server.d.ts +24 -2
- package/src/mcp/server.js +218 -18
- package/src/mcp/server.test.js +100 -0
- package/src/presets/ability_dispatch/workflow.js +8 -30
- package/src/presets/remote_control/config.d.ts +3 -0
- package/src/presets/remote_control/config.js +22 -24
- package/src/presets/remote_control/descriptor.d.ts +36 -0
- package/src/presets/remote_control/descriptor.js +267 -11
- package/src/presets/remote_control/handlers.d.ts +8 -0
- package/src/presets/remote_control/handlers.js +230 -26
- package/src/presets/remote_control/kit.d.ts +4 -2
- package/src/presets/remote_control/kit.js +106 -1
- package/src/presets/remote_control/kit.test.js +994 -0
- package/src/presets/remote_control/orchestrator.d.ts +6 -0
- package/src/presets/remote_control/orchestrator.js +36 -1
- package/src/presets/remote_control/specs.js +217 -61
- package/src/receipt.js +6 -3
- package/runtime/easynet-runtime-rs-0.27.14-x86_64-unknown-linux-gnu.tar.gz +0 -0
|
@@ -1,8 +1,71 @@
|
|
|
1
|
+
// EasyNet Axon for AgentNet
|
|
2
|
+
// =========================
|
|
3
|
+
//
|
|
4
|
+
// File: sdk/node/src/presets/remote_control/kit.ts
|
|
5
|
+
// Description: Node `RemoteControlCaseKit` MCP provider that wires handlers, tool specs, and managed tool streams.
|
|
6
|
+
//
|
|
7
|
+
// Protocol Responsibility:
|
|
8
|
+
// - Assembles remote-control tool specs, handler dispatch, and orchestrator lifecycle into one MCP provider surface.
|
|
9
|
+
// - Owns bridge or orchestrator cleanup for unary and streaming tool calls so callers do not leak resources.
|
|
10
|
+
//
|
|
11
|
+
// Implementation Approach:
|
|
12
|
+
// - Keeps entrypoints thin by delegating validation and business logic to focused handler/orchestrator modules.
|
|
13
|
+
// - Caches or scopes transport resources according to the SDK runtime model while preserving per-tenant correctness.
|
|
14
|
+
//
|
|
15
|
+
// Usage Contract:
|
|
16
|
+
// - Use this as the preset-level integration point when exposing EasyNet remote-control tools over MCP.
|
|
17
|
+
// - Factory injection points should preserve the same request/response semantics as the default orchestrator.
|
|
18
|
+
//
|
|
19
|
+
// Architectural Position:
|
|
20
|
+
// - Preset composition boundary above handler modules and below case/example entrypoints.
|
|
21
|
+
//
|
|
22
|
+
// Author: Silan.Hu
|
|
23
|
+
// Email: silan.hu@u.nus.edu
|
|
24
|
+
// Copyright (c) 2026-2027 easynet. All rights reserved.
|
|
25
|
+
import { consumeStream } from "../../mcp/server.js";
|
|
1
26
|
import { ensureRemoteControlNativeLibEnv, ensureNativeLibEnv, loadConfigFromEnv, loadRemoteControlConfigFromEnv, } from "./config.js";
|
|
2
27
|
import { resolveTenant } from "./descriptor.js";
|
|
3
|
-
import { handleCallRemoteTool, handleDeployAbility, handleDeployAbilityPackage, handleDiscoverNodes, handleDisconnectDevice, handleExecuteCommand, handleListRemoteTools, handlePackageAbility, handleUninstallAbility, } from "./handlers.js";
|
|
28
|
+
import { handleCallRemoteTool, handleCallRemoteToolStream, handleCreateAbility, handleDeployAbility, handleDeployAbilityPackage, handleDiscoverNodes, handleDisconnectDevice, handleDrainDevice, handleExecuteCommand, handleExportAbilitySkill, handleForgetAll, handleListAbilities, handleListRemoteTools, handlePackageAbility, handleUninstallAbility, handleRedeployAbility, } from "./handlers.js";
|
|
4
29
|
import { remoteControlToolSpecs } from "./specs.js";
|
|
5
30
|
import { buildOrchestrator } from "./orchestrator.js";
|
|
31
|
+
/**
|
|
32
|
+
* Wraps a remote tool stream with automatic orchestrator cleanup.
|
|
33
|
+
* Ensures the orchestrator is closed when the stream is consumed or explicitly closed.
|
|
34
|
+
* Close is idempotent — safe to call multiple times.
|
|
35
|
+
*/
|
|
36
|
+
class ManagedMcpToolStreamHandle {
|
|
37
|
+
inner;
|
|
38
|
+
cleanup;
|
|
39
|
+
stream;
|
|
40
|
+
closed = false;
|
|
41
|
+
constructor(inner, cleanup) {
|
|
42
|
+
this.inner = inner;
|
|
43
|
+
this.cleanup = cleanup;
|
|
44
|
+
this.stream = this.iterate();
|
|
45
|
+
}
|
|
46
|
+
close() {
|
|
47
|
+
if (this.closed) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
this.closed = true;
|
|
51
|
+
try {
|
|
52
|
+
this.inner.close();
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
this.cleanup();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async *iterate() {
|
|
59
|
+
try {
|
|
60
|
+
for await (const chunk of this.inner) {
|
|
61
|
+
yield chunk;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
this.close();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
6
69
|
export class RemoteControlCaseKit {
|
|
7
70
|
config;
|
|
8
71
|
orchestratorFactory;
|
|
@@ -26,9 +89,39 @@ export class RemoteControlCaseKit {
|
|
|
26
89
|
return remoteControlToolSpecs();
|
|
27
90
|
}
|
|
28
91
|
handleToolCall(name, args) {
|
|
92
|
+
if (name === "call_remote_tool_stream") {
|
|
93
|
+
// Buffer streaming result so callers that bypass handleToolCallStream
|
|
94
|
+
// (e.g. direct handleToolCall invocation) still get a valid response.
|
|
95
|
+
try {
|
|
96
|
+
const handle = this.handleToolCallStream(name, args);
|
|
97
|
+
if (handle) {
|
|
98
|
+
return consumeStream(handle);
|
|
99
|
+
}
|
|
100
|
+
return this.toolResult(true, { ok: false, error: "streaming not available" });
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
return this.toolResult(true, { ok: false, error: String(error) });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
29
106
|
const tenant = resolveTenant(args.tenant_id, this.config.tenant);
|
|
30
107
|
return this.withOrchestrator(tenant, (orchestrator) => this.dispatch(name, args, orchestrator, tenant));
|
|
31
108
|
}
|
|
109
|
+
/** Handle streaming calls for `call_remote_tool_stream`. Returns null for unknown tools. */
|
|
110
|
+
handleToolCallStream(name, args) {
|
|
111
|
+
if (name !== "call_remote_tool_stream") {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const tenant = resolveTenant(args.tenant_id, this.config.tenant);
|
|
115
|
+
const orchestrator = this.orchestratorFactory(this.config, tenant);
|
|
116
|
+
try {
|
|
117
|
+
const stream = handleCallRemoteToolStream(orchestrator, tenant, args);
|
|
118
|
+
return new ManagedMcpToolStreamHandle(stream, () => orchestrator.close());
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
orchestrator.close();
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
32
125
|
dispatch(name, args, orchestrator, tenant) {
|
|
33
126
|
switch (name) {
|
|
34
127
|
case "discover_nodes":
|
|
@@ -49,6 +142,18 @@ export class RemoteControlCaseKit {
|
|
|
49
142
|
return this.toolResultWithPayload(handleDeployAbility(orchestrator, tenant, args, this.config.signatureBase64));
|
|
50
143
|
case "execute_command":
|
|
51
144
|
return this.toolResultWithPayload(handleExecuteCommand(orchestrator, tenant, args, this.config.signatureBase64));
|
|
145
|
+
case "drain_device":
|
|
146
|
+
return this.toolResultWithPayload(handleDrainDevice(orchestrator, tenant, args));
|
|
147
|
+
case "build_ability_descriptor":
|
|
148
|
+
return this.toolResultWithPayload(handleCreateAbility(args));
|
|
149
|
+
case "export_ability_skill":
|
|
150
|
+
return this.toolResultWithPayload(handleExportAbilitySkill(args));
|
|
151
|
+
case "redeploy_ability":
|
|
152
|
+
return this.toolResultWithPayload(handleRedeployAbility(orchestrator, tenant, args, this.config.signatureBase64));
|
|
153
|
+
case "list_abilities":
|
|
154
|
+
return this.toolResultWithPayload(handleListAbilities(orchestrator, tenant, args));
|
|
155
|
+
case "forget_all":
|
|
156
|
+
return this.toolResultWithPayload(handleForgetAll(orchestrator, tenant, args));
|
|
52
157
|
default:
|
|
53
158
|
return this.toolResult(true, { ok: false, tenant_id: tenant, error: `unknown tool: ${name}` });
|
|
54
159
|
}
|